-
Notifications
You must be signed in to change notification settings - Fork 805
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
[Merged by Bors] - Optimise per_epoch_processing
low-hanging-fruit
#3254
Conversation
integer_sqrt
integer_sqrt
Nice! 🎉 Regarding optimising the other base reward calls, we could consider caching the whole lighthouse/consensus/state_processing/src/per_epoch_processing/altair/participation_cache.rs Lines 133 to 142 in a3e396c
lighthouse/consensus/state_processing/src/per_epoch_processing/altair/participation_cache.rs Lines 155 to 159 in a3e396c
That's a larger and more invasive change however, and seeing as this change combined with the Vec map already yields enormous speed-ups, maybe we take the simple win and merge this almost as-is 😍 |
commit 3870406 Author: Paul Hauner <[email protected]> Date: Thu Jun 9 18:13:46 2022 +1000 Swap hashmap to vec
commit 3c2a742 Author: Paul Hauner <[email protected]> Date: Thu Jun 9 18:54:41 2022 +1000 Avoid recomputing previous_epoch
integer_sqrt
per_epoch_processing
low-hanging-fruit
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.
This is awesome!
I've thoroughly checked every line of this PR and I'm confident in its correctness.
I re-ran the benchmark from #3229 and found a whopping 30% speed-up on top of the ~10% speed-up from that PR. That means our next release should be 37% faster on such blocks. It's worth noting that the benchmark is dominated by tree hashing, so the speed-up isn't quite as huge as the 3x speed-up for epoch processing without tree hashing. https://docs.google.com/spreadsheets/d/1kfPRVTI2NL5UbDl7WAHLA9gWpaK22D9C22dplzjJ7dw/edit#gid=0
I'm super excited to ship this and get it running on mainnet! 🎉
bors r+ |
## Issue Addressed NA ## Proposed Changes - Uses a `Vec` in `SingleEpochParticipationCache` rather than `HashMap` to speed up processing times at the cost of memory usage. - Cache the result of `integer_sqrt` rather than recomputing for each validator. - Cache `state.previous_epoch` rather than recomputing it for each validator. ### Benchmarks Benchmarks on a recent mainnet state using #3252 to get timing. #### Without this PR ``` lcli skip-slots --state-path /tmp/state-0x3cdc.ssz --partial-state-advance --slots 32 --state-root 0x3cdc33cd02713d8d6cc33a6dbe2d3a5bf9af1d357de0d175a403496486ff845e --runs 10 [2022-06-09T08:21:02Z INFO lcli::skip_slots] Using mainnet spec [2022-06-09T08:21:02Z INFO lcli::skip_slots] Advancing 32 slots [2022-06-09T08:21:02Z INFO lcli::skip_slots] Doing 10 runs [2022-06-09T08:21:02Z INFO lcli::skip_slots] State path: "/tmp/state-0x3cdc.ssz" SSZ decoding /tmp/state-0x3cdc.ssz: 43ms [2022-06-09T08:21:03Z INFO lcli::skip_slots] Run 0: 245.718794ms [2022-06-09T08:21:03Z INFO lcli::skip_slots] Run 1: 245.364782ms [2022-06-09T08:21:03Z INFO lcli::skip_slots] Run 2: 255.866179ms [2022-06-09T08:21:04Z INFO lcli::skip_slots] Run 3: 243.838909ms [2022-06-09T08:21:04Z INFO lcli::skip_slots] Run 4: 250.431425ms [2022-06-09T08:21:04Z INFO lcli::skip_slots] Run 5: 248.68765ms [2022-06-09T08:21:04Z INFO lcli::skip_slots] Run 6: 262.051113ms [2022-06-09T08:21:05Z INFO lcli::skip_slots] Run 7: 264.293967ms [2022-06-09T08:21:05Z INFO lcli::skip_slots] Run 8: 293.202007ms [2022-06-09T08:21:05Z INFO lcli::skip_slots] Run 9: 264.552017ms ``` #### With this PR: ``` lcli skip-slots --state-path /tmp/state-0x3cdc.ssz --partial-state-advance --slots 32 --state-root 0x3cdc33cd02713d8d6cc33a6dbe2d3a5bf9af1d357de0d175a403496486ff845e --runs 10 [2022-06-09T08:57:59Z INFO lcli::skip_slots] Run 0: 73.898678ms [2022-06-09T08:57:59Z INFO lcli::skip_slots] Run 1: 75.536978ms [2022-06-09T08:57:59Z INFO lcli::skip_slots] Run 2: 75.176104ms [2022-06-09T08:57:59Z INFO lcli::skip_slots] Run 3: 76.460828ms [2022-06-09T08:57:59Z INFO lcli::skip_slots] Run 4: 75.904195ms [2022-06-09T08:58:00Z INFO lcli::skip_slots] Run 5: 75.53077ms [2022-06-09T08:58:00Z INFO lcli::skip_slots] Run 6: 74.745572ms [2022-06-09T08:58:00Z INFO lcli::skip_slots] Run 7: 75.823489ms [2022-06-09T08:58:00Z INFO lcli::skip_slots] Run 8: 74.892055ms [2022-06-09T08:58:00Z INFO lcli::skip_slots] Run 9: 76.333569ms ``` ## Additional Info NA
per_epoch_processing
low-hanging-fruitper_epoch_processing
low-hanging-fruit
Issue Addressed
NA
Proposed Changes
Vec
inSingleEpochParticipationCache
rather thanHashMap
to speed up processing times at the cost of memory usage.integer_sqrt
rather than recomputing for each validator.state.previous_epoch
rather than recomputing it for each validator.Benchmarks
Benchmarks on a recent mainnet state using #3252 to get timing.
Without this PR
With this PR:
Additional Info
NA