perf: defer ExecutedBlock drop to background thread#22080
Draft
perf: defer ExecutedBlock drop to background thread#22080
Conversation
When blocks are evicted from the in-memory tree (after persistence or finalization), the engine thread must drop ExecutedBlock values which contain Arc<TrieUpdatesSorted>. Dropping these involves recursive deallocation of BranchNodeCompact chains with inner Arc<Vec<B256>> hash vectors. Profile data shows this costs ~2% of engine thread time. Move the drop to a rayon::spawn background task so the engine thread can immediately continue processing. Amp-Thread-ID: https://ampcode.com/threads/T-019c4dab-6735-7327-90fb-3a9067d10d9e
Contributor
|
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.
Summary
When blocks are evicted from the in-memory
TreeStateafter persistence,ExecutedBlockdrops happen on the engine thread. TheTrieUpdatesSorteddrop cascade (Arc<Vec<B256>>insideBranchNodeCompact) triggers hundreds of small deallocations through cold cache lines, consuming ~2% of engine thread CPU. This PR defers evicted block drops to a rayon background task.Changes
remove_canonical_until()andprune_finalized_sidechains()return evicted blocks instead of dropping themremove_until()collects evicted blocks and defers drop viarayon::spawn