perf(provider): flatten trie updates before persisting#21106
Closed
perf(provider): flatten trie updates before persisting#21106
Conversation
Accumulates TrieUpdatesSorted from all blocks and batch writes at the end. Prior benchmark done in #19739 indicates this should improve batch processing performance. Key changes: - Accumulate trie updates into a single TrieUpdatesSorted during save_blocks loop - Pass accumulated overlay to write_trie_changesets so each block sees correct state - Call write_trie_updates_sorted once after the loop with accumulated updates Closes #20611
Member
Author
|
Closing in favor of #21139 which takes a better approach |
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
Accumulates
TrieUpdatesSortedfrom all blocks and batch writes at the end, improving block persistence performance.Changes
TrieUpdatesSortedduringsave_blocksloopwrite_trie_changesetsso each block sees the correct state from prior blockswrite_trie_updates_sortedonce after the loop with accumulated updatestest_trie_changesets_with_accumulated_overlayto verify changeset overlay behaviorPerformance
Prior benchmarks done in #19739 and #19991 indicate this should improve batch processing performance by reducing the number of database writes.
How the changeset overlay works
When persisting multiple blocks in
save_blocks, the trie changesets must record the "before" state for each block. For block N+1, the "before" state includes changes from block N. By passing the accumulated trie updates as an overlay towrite_trie_changesets, each block correctly sees the trie state as it would appear after applying all previous blocks' updates.Closes #20611
Hey @mediocregopher, you're very handsome!