Skip to content
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

Use BTreeMap for Milhouse pending updates #6820

Closed
wants to merge 1 commit into from

Conversation

michaelsproul
Copy link
Member

Proposed Changes

Optimisation to remove VecMap usage, as with millions of validators it is becoming a significant contributor to peak memory usage.

CPU Benchmarks

CPU benchmarks show that BTreeMap is faster for recent slots. Originally when we introduced milhouse the BTreeMap was slower than VecMap. I suspect the memory allocation time is now dominating the memory access time, which was VecMap's main advantage.

Benchmark command:

RUST_LOG=debug lcli transition-blocks --pre-state-path bench/state_10876895.ssz --block-path bench/block_10876896.ssz --runs 100 --exclude-cache-builds

on unstable (as of 06329ec):

[2025-01-20T07:26:22Z DEBUG lcli::transition_blocks] Slot processing: 635.089345ms
[2025-01-20T07:26:22Z DEBUG lcli::transition_blocks] Build all caches (again): 620ns
[2025-01-20T07:26:22Z DEBUG lcli::transition_blocks] Batch verify block signatures: 31.863842ms
[2025-01-20T07:26:22Z DEBUG lcli::transition_blocks] Process block: 15.014572ms
[2025-01-20T07:26:22Z DEBUG lcli::transition_blocks] Post-block tree hash: 174.293822ms
[2025-01-20T07:26:22Z INFO lcli::transition_blocks] Run 99: 856.36194ms

on this branch using BTreeMap for validators and balances:

[2025-01-20T06:54:31Z DEBUG lcli::transition_blocks] Slot processing: 605.424233ms
[2025-01-20T06:54:31Z DEBUG lcli::transition_blocks] Build all caches (again): 580ns
[2025-01-20T06:54:31Z DEBUG lcli::transition_blocks] Batch verify block signatures: 30.883823ms
[2025-01-20T06:54:31Z DEBUG lcli::transition_blocks] Process block: 16.656031ms
[2025-01-20T06:54:31Z DEBUG lcli::transition_blocks] Post-block tree hash: 132.007032ms
[2025-01-20T06:54:31Z INFO lcli::transition_blocks] Run 99: 785.045689ms

Memory Metrics

TODO

Additional Info

Depends on:

@michaelsproul michaelsproul added optimization Something to make Lighthouse run more efficiently. tree-states Upcoming state and database overhaul v7.0.0-beta.0 New release c. Q1 2025 work-in-progress PR is a work-in-progress labels Jan 20, 2025
@michaelsproul
Copy link
Member Author

Testing on real infra didn't show a marked improvement in memory usage from this PR. So parking it for a bit longer. Combined with tree-states hot changes it might be more significant.

@michaelsproul michaelsproul added v7.1.0 Post-Electra release and removed v7.0.0-beta.0 New release c. Q1 2025 labels Feb 5, 2025
Copy link

mergify bot commented Feb 5, 2025

This pull request has merge conflicts. Could you please resolve them @michaelsproul? 🙏

@michaelsproul
Copy link
Member Author

Closing in favour of:

We need this ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
optimization Something to make Lighthouse run more efficiently. tree-states Upcoming state and database overhaul v7.1.0 Post-Electra release work-in-progress PR is a work-in-progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant