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

Change structure of Transactions for faster block decoding #6609

Draft
wants to merge 20 commits into
base: unstable
Choose a base branch
from

Conversation

paulhauner
Copy link
Member

@paulhauner paulhauner commented Nov 25, 2024

Issue Addressed

NA

Blockers

Proposed Changes

Reduces the time to decode a block by ~15% by reducing the effort needed to decode execution_payload.transactions.

Previously we stored transactions as VariableList<VariableList>. Now we store them as (Vec<offsets>, Vec<values>), where each offset points to the start of a new transaction in values. This is how the data is represented as SSZ.

The prior implementation required N+1 allocations, where this requires 2 allocations.

Additional Info

NA

Before

lcli transition-blocks --block-path /tmp/block-10472248.ssz --pre-state-path /tmp/pre-state-10472248.ssh --runs 10
[2024-11-25T05:16:37Z INFO  lcli::transition_blocks] Using mainnet spec
[2024-11-25T05:16:37Z INFO  lcli::transition_blocks] Doing 10 runs
[2024-11-25T05:16:37Z INFO  lcli::transition_blocks] Config { no_signature_verification: false, exclude_cache_builds: false, exclude_post_block_thc: false }
[2024-11-25T05:16:37Z DEBUG lcli::transition_blocks] SSZ decoding /tmp/block-10472248.ssz: 3.534442ms
[2024-11-25T05:16:37Z DEBUG lcli::transition_blocks] SSZ decoding /tmp/block-10472248.ssz: 3.727088ms
[2024-11-25T05:16:37Z DEBUG lcli::transition_blocks] SSZ decoding /tmp/block-10472248.ssz: 3.65126ms
[2024-11-25T05:16:37Z DEBUG lcli::transition_blocks] SSZ decoding /tmp/block-10472248.ssz: 3.520166ms
[2024-11-25T05:16:37Z DEBUG lcli::transition_blocks] SSZ decoding /tmp/block-10472248.ssz: 3.517495ms
[2024-11-25T05:16:37Z DEBUG lcli::transition_blocks] SSZ decoding /tmp/block-10472248.ssz: 3.659826ms
[2024-11-25T05:16:37Z DEBUG lcli::transition_blocks] SSZ decoding /tmp/block-10472248.ssz: 3.532312ms
[2024-11-25T05:16:37Z DEBUG lcli::transition_blocks] SSZ decoding /tmp/block-10472248.ssz: 3.485217ms
[2024-11-25T05:16:37Z DEBUG lcli::transition_blocks] SSZ decoding /tmp/block-10472248.ssz: 3.489904ms
[2024-11-25T05:16:37Z DEBUG lcli::transition_blocks] SSZ decoding /tmp/block-10472248.ssz: 3.495821ms

After

lcli transition-blocks --block-path /tmp/block-10472248.ssz --pre-state-path /tmp/pre-state-10472248.ssh --runs 10
[2024-11-25T05:22:26Z INFO  lcli::transition_blocks] Using mainnet spec
[2024-11-25T05:22:26Z INFO  lcli::transition_blocks] Doing 10 runs
[2024-11-25T05:22:26Z INFO  lcli::transition_blocks] Config { no_signature_verification: false, exclude_cache_builds: false, exclude_post_block_thc: false }
[2024-11-25T05:22:26Z DEBUG lcli::transition_blocks] SSZ decoding /tmp/block-10472248.ssz: 3.156101ms
[2024-11-25T05:22:26Z DEBUG lcli::transition_blocks] SSZ decoding /tmp/block-10472248.ssz: 3.086956ms
[2024-11-25T05:22:26Z DEBUG lcli::transition_blocks] SSZ decoding /tmp/block-10472248.ssz: 3.085763ms
[2024-11-25T05:22:26Z DEBUG lcli::transition_blocks] SSZ decoding /tmp/block-10472248.ssz: 3.197391ms
[2024-11-25T05:22:26Z DEBUG lcli::transition_blocks] SSZ decoding /tmp/block-10472248.ssz: 3.111297ms
[2024-11-25T05:22:26Z DEBUG lcli::transition_blocks] SSZ decoding /tmp/block-10472248.ssz: 3.085961ms
[2024-11-25T05:22:26Z DEBUG lcli::transition_blocks] SSZ decoding /tmp/block-10472248.ssz: 3.089851ms
[2024-11-25T05:22:26Z DEBUG lcli::transition_blocks] SSZ decoding /tmp/block-10472248.ssz: 3.076389ms
[2024-11-25T05:22:26Z DEBUG lcli::transition_blocks] SSZ decoding /tmp/block-10472248.ssz: 3.082601ms
[2024-11-25T05:22:26Z DEBUG lcli::transition_blocks] SSZ decoding /tmp/block-10472248.ssz: 3.07679ms

@paulhauner paulhauner added the work-in-progress PR is a work-in-progress label Nov 25, 2024
@michaelsproul
Copy link
Member

Paul the Optimiser returns 🤩

@michaelsproul
Copy link
Member

omg I did not mean to close that, sorry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
work-in-progress PR is a work-in-progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants