Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Parallelize accountant #106

Merged
merged 6 commits into from
Apr 5, 2018
Merged

Conversation

garious
Copy link
Contributor

@garious garious commented Apr 4, 2018

This is not yet integrated into AccountantSkel, so don't expect the top-level demo benchmark to change, but includes a microbenchmark that demonstrates that performance doubles compared to the single-threaded version.

Also, before adding to AccountantSkel, we need to ensure all transactions commute.

garious added 2 commits April 4, 2018 12:33
Before this change, parallel transaction processing required locking
the full accountant. Since we only call one method,
process_verified_transaction, the global lock equates to doing no
parallelization at all.  With this change, we only lock the data that's
being written to.
@garious garious requested review from aeyakovenko and sakridge April 4, 2018 18:55
@garious
Copy link
Contributor Author

garious commented Apr 4, 2018

So technically, transactions posted by the leader don't need to commute, but we'd need to lock the historian before applying any changes, and if we did that in the current code, you'd lose all parallelization.

@codecov-io
Copy link

codecov-io commented Apr 4, 2018

Codecov Report

Merging #106 into master will increase coverage by 0.13%.
The diff coverage is 98.43%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #106      +/-   ##
==========================================
+ Coverage   95.69%   95.83%   +0.13%     
==========================================
  Files          16       16              
  Lines        1324     1344      +20     
==========================================
+ Hits         1267     1288      +21     
+ Misses         57       56       -1
Impacted Files Coverage Δ
src/accountant.rs 94.81% <98.43%> (+0.63%) ⬆️
src/signature.rs 100% <0%> (+7.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 123d7c6...8d425e1. Read the comment docs.


if let Some(ref payment) = plan.final_payment() {
apply_payment(&mut self.balances, payment);
apply_payment(&mut self.balances.write().unwrap(), payment);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will it try to get write lock for balances twice?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in the case the transaction requires no witnesses, it'll lock balances for the from cell and again for the to cell. Once we switch to per cell locks, it'll be two separate locks anyway.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, a subtlety of Rust, by not putting balances into variable, it's only in scope while the righthand side of that expression is evaluated. If I put the first instance into a variable, then the second would immediately cause a panic.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok cool. yea it's not super clear.

garious added 4 commits April 4, 2018 16:01
This allows us to use read-locks for balances most of the time. We
only lock the full table if we need to add one.
This will allow for additional concurrency as well as give the server
a means of garbage-collecting old signatures.
@garious
Copy link
Contributor Author

garious commented Apr 4, 2018

With per-cell locking and sorting signatures by last_id, the benchmark is now processing 4k transactions in just under 5ms

@garious garious merged commit fc69d31 into solana-labs:master Apr 5, 2018
vkomenda pushed a commit to vkomenda/solana that referenced this pull request Aug 29, 2021
segfaultdoc pushed a commit to jito-labs/solana that referenced this pull request Aug 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants