[autoopt] 20260414-008-sparse-prune-retained-slices#23508
Draft
mediocregopher wants to merge 1 commit intomainfrom
Draft
[autoopt] 20260414-008-sparse-prune-retained-slices#23508mediocregopher wants to merge 1 commit intomainfrom
mediocregopher wants to merge 1 commit intomainfrom
Conversation
Amp-Thread-ID: https://ampcode.com/threads/T-019d8cbd-5049-75c8-9a78-0c94eb59a354 Co-authored-by: Amp <amp@ampcode.com>
Member
Author
|
derek bench |
Contributor
|
Your PR title doesn't follow the Conventional Commit guidelines. Example of valid titles:
Usage:
Breaking Changes Breaking changes are noted by using an exclamation mark. For example:
Help For more information, follow the guidelines here: https://www.conventionalcommits.org/en/v1.0.0/ |
Member
|
✅ Benchmark complete! View job Benchmark Results
200 blocks, 100 warmup Wait Time BreakdownPersistence Wait
Trie Cache Update Wait
Execution Cache Update Wait
ChartsGrafana Dashboard |
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.



Reuse sorted retained leaves during sparse-trie pruning
Evidence
reth_trie_sparse::arena::ArenaSparseSubtrie::prunewith 6,150 exclusive samples on the sparse-trie maintenance path.SparseStateTrie::prunealready computes one LFU-selected retained set for the whole prune pass, but the arena and parallel trie implementations each cloned and re-sortedretained_leavesagain inside every prune call.retained_slots_by_address, so most of that clone/sort work was avoidable bookkeeping rather than trie logic.Hypothesis
If we sort retained account leaves once in
SparseStateTrie::pruneand let sparse-trie prune implementations borrow already sorted slices instead of cloning them, gas throughput improves by ~0.2-0.6% because sparse-trie pruning does less repeated leaf-list allocation and sorting on the hot cache-maintenance path.Success Metric
Plan
crates/trie/sparse/src/state.rs.crates/trie/sparse/src/arena/mod.rsandcrates/trie/sparse/src/parallel.rsto borrow sortedretained_leaveswhen possible and only allocate on unsorted fallback inputs.cargo check -p reth-trie-sparseandcargo test -p reth-trie-sparse prune --lib.