-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hash stored accounts in bg #16157
Hash stored accounts in bg #16157
Conversation
this pr: (improvement is in store_us and overall time) master: |
first prototype: #15617 |
Codecov Report
@@ Coverage Diff @@
## master #16157 +/- ##
=======================================
Coverage 80.0% 80.0%
=======================================
Files 410 410
Lines 109506 109592 +86
=======================================
+ Hits 87674 87761 +87
+ Misses 21832 21831 -1 |
runtime/src/accounts_db.rs
Outdated
LoadedAccount::Stored(stored_account_meta) => &stored_account_meta.hash, | ||
LoadedAccount::Cached((_, cached_account)) => &cached_account.hash, | ||
LoadedAccount::Stored(stored_account_meta) => *stored_account_meta.hash, | ||
LoadedAccount::Cached((_, cached_account)) => cached_account.hash(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah clever, so if the hash isn't computed yet by the background service by this point, (for things like bank.freeze()
that need the hash), it'll compute it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I am just implementing the required blocking, lazy behavior in a way that seems correct, consistent, performant. I think it fits Rust idioms sufficiently.
99aa104
to
d5a04fb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good and super cool to have higher performance
automerge label removed due to a CI failure |
Problem
While processing a slot, the same account can be written to many times.
Hashing accounts is not free and gets expensive with large data. Hashing an account that is not the final update is not usually necessary.
Summary of Changes
When an account is stored to the accounts_cache, don't hash the contents first - instead use None. When a caller requires a hash, and a hash hasn't been calculated, calculate it and store it. A background thread processes items that are added to the accounts_cache, calculates the hash and updates the cached item in accounts_cache.
Fixes #