-
Notifications
You must be signed in to change notification settings - Fork 742
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
In-memory tree states #5533
In-memory tree states #5533
Conversation
I pushed a commit 970f3df which seems to have made memory usage less spikey on a restart (see 12:30 in chart). The problem previously was that the head state would not get cached in the The memory usage is still a bit spikier than I'd like, and this is despite a complete absence of cache misses. This may be memory usage unrelated to the state cache. Even so, tree-states is using consistently less memory with lower spikes than The yellow line at the bottom is this branch, the rest are running variants of stable/unstable. |
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.
🚀
@mergify queue |
🛑 The pull request has been removed from the queue
|
@@ -4529,10 +4404,11 @@ impl<T: BeaconChainTypes> BeaconChain<T> { | |||
let block = self | |||
.get_blinded_block(&parent_block_root)? | |||
.ok_or(Error::MissingBeaconBlock(parent_block_root))?; | |||
let state = self | |||
.get_state(&block.state_root(), Some(block.slot()))? | |||
let (state_root, state) = self |
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.
I think the log above needs to be updated to remove snapshot cache:
lighthouse/beacon_node/beacon_chain/src/beacon_chain.rs
Lines 4398 to 4403 in 970f3df
info!( | |
self.log, | |
"Missed snapshot cache during withdrawals calculation"; | |
"slot" => proposal_slot, | |
"parent_block_root" => ?parent_block_root | |
); |
Some minor comments:
|
@mergify dequeue |
✅ The pull request has been removed from the queue
|
sorry @jimmygchen didn't realize you were mid-review! |
All good, happy to merge this as it's gone through some testing and you've already done a round of review! I'd be keen to get this in so
|
@jimmygchen has expressed offline he's good with merging and allowing feedback resolution in a followup PR so as to avoid conflicts |
@mergify queue |
🛑 The pull request has been removed from the queue
|
@mergify requeue |
✅ This pull request will be re-embarked automaticallyThe followup |
✅ The pull request has been merged automaticallyThe pull request has been merged automatically at 6196289 |
} | ||
set_gauge_by_usize( | ||
&BLOCK_PROCESSING_SNAPSHOT_CACHE_SIZE, | ||
beacon_chain.store.state_cache_len(), |
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.
Can we rename the metrics to BLOCK_PROCESSING_STATE_CACHE_SIZE
instead?
Issue Addressed
This is the memory-only portion of
tree-states
, i.e. without any database schema changes.Proposed Changes
BeaconState
cheap to clone thanks to persistent data structures from milhouse.block_production_state
.StateProcessingStrategy
. This could cause us to do more tree hashing in the case of an attester shuffling cache miss, but this is mitigated by 1) tree-states has faster tree hashing due to structural sharing, 2) the state cache is likely to hit even when the shuffling cache misses. It is less risky to remove the concept of inconsistent states altogether so that they can't end up in the newstate_cache
and poison it. We can re-optimise this codepath in future by adopting theHotStateSummary
changes from fulltree-states
.