-
Notifications
You must be signed in to change notification settings - Fork 784
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
Hierarchical state diffs #5978
Hierarchical state diffs #5978
Conversation
I get a compilation error from xdelta3 trying to compile this branch: EDIT: Fixed (cropped previous text because it's long) |
looks like it might be a Mac thing I had to fork xdelta3 already, we should move it under sigp and patch it |
TODOsEDIT: completed |
TODO ~ Some metrics that we should add:
|
* Add store cache size metrics * Add compress timer metrics * Add diff apply compute timer metrics * Add diff buffer cache hit metrics * Add hdiff buffer load times * Add blocks replayed metric * Move metrics to store * Future proof some metrics --------- Co-authored-by: Michael Sproul <[email protected]>
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.
Looks really good, thanks for addressing the comments! 🎉
I don't fully understand all the database details, but I've reviewed all the changes and I don't see any obvious issues.
I believe this is good to go, and happy to help optimise further if we need to.
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.
Testing this we noted much worse performance of the binary patch library than we expected originally. The BeaconState has grown significantly since Michael did the original research of what diff algorithm to use. Despite Electra activating in some months there's no guarantee that the network will consolidate, so rampant state growth is a concern.
Currently it takes 1.3 sec to compute a diff on average on a healthy holesky node.
State size (MB) | ||||
---|---|---|---|---|
% Supply staked | Validators (M) | 0% bloat | 100% bloat | 200% bloat |
100 | 3.75 | 543.75 | 1087.5 | 1631.25 |
80 | 3 | 435 | 870 | 1305 |
60 | 2.25 | 326.25 | 652.5 | 978.75 |
40 | 1.5 | 217.5 | 435 | 652.5 |
30 | 1.125 | 163.125 | 326.25 | 489.375 |
20 | 0.75 | 108.75 | 217.5 | 326.25 |
There's a possibility of the BeaconState growing close to 1GB. I run some benchmarks on our diff library, and the time to compute a diff is (random mutations of total size diff bytes), (tested on an M2 chip)
data size bytes | diff bytes | compute diff time (ms) |
---|---|---|
2e8 (today's size) | 1e3 | 584.03 |
2e8 | 1e4 | 635.24 |
2e8 | 1e5 | 778.79 |
2e8 | 1e6 | 1507.0 |
1e9 (future size) | 1e3 | 4895.6 |
1e9 | 1e4 | 3885.0 |
1e9 | 1e5 | 6301.1 |
1e9 | 1e6 | 15858.0 |
For 1GB input data those are pretty terrifying numbers. I'm hitting Request changes to:
- Make this branch future proof to allow us to improve the diff algorithm in the future. For example, version the diffs and use more advance strategies latter
- Come up with a better diff algorithm now
Versioning the diff algorithm sounds like a great idea. I also think we could probably include #6556 |
* Split hdiff computation * Dedicated logic for historical roots and summaries * Benchmark against real states * Mutated source? * Version the hdiff * Add lighthouse DB config for hierarchy exponents * Tidy up hierarchy exponents flag * Apply suggestions from code review Co-authored-by: Michael Sproul <[email protected]> * Address PR review * Remove hardcoded paths in benchmarks * Delete unused function in benches * lint --------- Co-authored-by: Michael Sproul <[email protected]>
I'll merge this PR first and then resolve merge conflicts: |
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 merged automaticallyThe pull request has been merged automatically at 9fdd53d |
* Start extracting freezer changes for tree-states * Remove unused config args * Add comments * Remove unwraps * Subjective more clear implementation * Clean up hdiff * Update xdelta3 * Tree states archive metrics (sigp#6040) * Add store cache size metrics * Add compress timer metrics * Add diff apply compute timer metrics * Add diff buffer cache hit metrics * Add hdiff buffer load times * Add blocks replayed metric * Move metrics to store * Future proof some metrics --------- Co-authored-by: Michael Sproul <[email protected]> * Port and clean up forwards iterator changes * Add and polish hierarchy-config flag * Merge remote-tracking branch 'origin/unstable' into tree-states-archive * Cleaner errors * Fix beacon_chain test compilation * Merge remote-tracking branch 'origin/unstable' into tree-states-archive * Patch a few more freezer block roots * Fix genesis block root bug * Fix test failing due to pending updates * Beacon chain tests passing * Merge remote-tracking branch 'origin/unstable' into tree-states-archive * Merge remote-tracking branch 'origin/unstable' into tree-states-archive * Fix doc lint * Implement DB schema upgrade for hierarchical state diffs (sigp#6193) * DB upgrade * Add flag * Delete RestorePointHash * Update docs * Update docs * Implement hierarchical state diffs config migration (sigp#6245) * Implement hierarchical state diffs config migration * Review PR * Remove TODO * Set CURRENT_SCHEMA_VERSION correctly * Fix genesis state loading * Re-delete some PartialBeaconState stuff --------- Co-authored-by: Michael Sproul <[email protected]> * Merge remote-tracking branch 'origin/unstable' into tree-states-archive * Fix test compilation * Update schema downgrade test * Fix tests * Fix null anchor migration * Merge remote-tracking branch 'origin/unstable' into tree-states-archive * Fix tree states upgrade migration (sigp#6328) * Towards crash safety * Fix compilation * Move cold summaries and state roots to new columns * Rename StateRoots chunked field * Update prune states * Clean hdiff CLI flag and metrics * Fix "staged reconstruction" * Merge remote-tracking branch 'origin/unstable' into tree-states-archive * Fix alloy issues * Fix staged reconstruction logic * Prevent weird slot drift * Remove "allow" flag * Update CLI help * Remove FIXME about downgrade * Merge remote-tracking branch 'origin/unstable' into tree-states-archive * Remove some unnecessary error variants * Fix new test * Tree states archive - review comments and metrics (sigp#6386) * Review PR comments and metrics * Comments * Add anchor metrics * drop prev comment * Update metadata.rs * Apply suggestions from code review --------- Co-authored-by: Michael Sproul <[email protected]> * Update beacon_node/store/src/hot_cold_store.rs Co-authored-by: Lion - dapplion <[email protected]> * Merge remote-tracking branch 'origin/unstable' into tree-states-archive * Clarify comment and remove anchor_slot garbage * Simplify database anchor (sigp#6397) * Simplify database anchor * Update beacon_node/store/src/reconstruct.rs * Add migration for anchor * Fix and simplify light_client store tests * Fix incompatible config test * Merge remote-tracking branch 'origin/unstable' into tree-states-archive * Merge remote-tracking branch 'origin/unstable' into tree-states-archive * More metrics * Merge remote-tracking branch 'origin/unstable' into tree-states-archive * New historic state cache (sigp#6475) * New historic state cache * Add more metrics * State cache hit rate metrics * Fix store metrics * More logs and metrics * Fix logger * Ensure cached states have built caches :O * Replay blocks in preference to diffing * Two separate caches * Distribute cache build time to next slot * Re-plumb historic-state-cache flag * Clean up metrics * Update book * Update beacon_node/store/src/hdiff.rs Co-authored-by: Lion - dapplion <[email protected]> * Update beacon_node/store/src/historic_state_cache.rs Co-authored-by: Lion - dapplion <[email protected]> --------- Co-authored-by: Lion - dapplion <[email protected]> * Update database docs * Update diagram * Merge remote-tracking branch 'origin/unstable' into tree-states-archive * Update lockbud to work with bindgen/etc * Correct pkg name for Debian * Remove vestigial epochs_per_state_diff * Merge remote-tracking branch 'origin/unstable' into tree-states-archive * Markdown lint * Merge remote-tracking branch 'origin/unstable' into tree-states-archive * Address Jimmy's review comments * Simplify ReplayFrom case * Fix and document genesis_state_root * Typo Co-authored-by: Jimmy Chen <[email protected]> * Merge branch 'unstable' into tree-states-archive * Compute diff of validators list manually (sigp#6556) * Split hdiff computation * Dedicated logic for historical roots and summaries * Benchmark against real states * Mutated source? * Version the hdiff * Add lighthouse DB config for hierarchy exponents * Tidy up hierarchy exponents flag * Apply suggestions from code review Co-authored-by: Michael Sproul <[email protected]> * Address PR review * Remove hardcoded paths in benchmarks * Delete unused function in benches * lint --------- Co-authored-by: Michael Sproul <[email protected]> * Test hdiff binary format stability (sigp#6585) * Merge remote-tracking branch 'origin/unstable' into tree-states-archive * Add deprecation warning for SPRP * Update xdelta to get rid of duplicate deps * Document test
Proposed Changes
This PR contains the freezer DB changes from the main
tree-states
branch, bringing the small & efficient archive node database to stable Lighthouse 🎉Additional Info
(From @dapplion): Some resources to get up to speed with HDiff concepts: