-
Notifications
You must be signed in to change notification settings - Fork 9
feat: optimised initial state update for pruning #563
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
base: unstable
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
... and 19 files with indirect coverage changes
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
Pull request overview
This PR optimizes the initial state update operation during pruning, achieving approximately 20.9% throughput improvement and 17.2% latency reduction. The optimization restructures the database write strategy from an interleaved approach to a more efficient two-phase sequential approach.
Key changes:
- Restructured prune mode database operations to use sequential batch deletion followed by batch writes instead of interleaved operations
- Corrected timing measurement to include all fetch operations (trie updates and block hashes) in the reported fetch duration
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/optimism/trie/src/prune/pruner.rs | Moved fetch_duration measurement to after block hash fetches for accurate timing attribution |
| crates/optimism/trie/src/db/store.rs | Refactored persist_history_batch prune mode logic to use two-phase approach: batch delete all block 0 entries, then batch write non-tombstones |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
emhane
left a comment
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.
lgtm
| // Drop current cursor to start clean for Phase 1 | ||
| drop(cur); |
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.
nice
| // Phase 1: Batch Delete (Sequential) | ||
| // Remove all existing state at Block 0 for these keys. |
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.
thank you for the numbered steps in these code comments, improves readability
Closes #562
Validated the optimization by rewriting an initial state with N=50,000 updated entries.
bench: 180e132