feat: implement BalancesTreeCache#7084
Merged
Merged
Conversation
Contributor
Author
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Motivation
balancestree from scratch and it causes memory spikes atprocessRewardsAndPenaltiesstep (10m) chart:while after a state is finalized, we remove checkpoint state and don't use it anymore. We can recreate the
balancestree using that unusedbalancestree from that state leveraging feat: ListUintNum64Type create ViewDU from existing tree ssz#402see also Improve processRewardsAndPenalties #6229
Description
BalancesTreeCachewhich is populated after we remove a checkpoint state, and consume by epoch transition using same design of feat: async shuffling refactor #6938IBalancesTreeCacheinterface and consume it if existsBalancesTreeCacheand put that toEpochCacheListUintNum64Type.toViewDU(value, viewDU)Resolves #6229
Testing
processRewardsAndPenalties10m is improved a lot, there are 2 spikes in 12h time frame, most likely due tobatchHashTreeRoot()we used insideListUintNum64Type.toViewDU(value, viewDU)prepareNextEpochis saved ~350ms because we hashedstate.balancesinListUintNum64Type.toViewDU(value, viewDU), and that's majority of hash work forprepareNextEpochstate.hashTreeRoot()isnota little bit confusing, but majority of work is done by this work andstate.validators.commit()