bank: add lightweight bank hash cache to reduce bank forks usage #3061
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
An upcoming change needs to access the replayed bank hash of select slots. It is overkill to grab the
bank_forks
lock for such scenarios.Summary of Changes
Similar to the
root_bank_cache
, split out a cache just for the latestbank_hash
of replayed slots. When a slot is dumped, the cache is not updated which should be fine for our usage. This cache is pruned alongsidebank_forks
as to keep in sync.Implementation details:
bank_forks
bank
is inserted intobank_forks
, store a reference to the cache in the bank.bank
is frozen, write lock the cache and insert the new bank hash.bank_forks
and read lock it when they wish to query bank hash without having to read lockbank_forks
.