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

feat: add trie prefetch when executing blocks #56

Merged
merged 5 commits into from
Sep 3, 2024

Conversation

keefel
Copy link
Contributor

@keefel keefel commented Jul 8, 2024

Description

This pull request enhances merkleization efficiency by prefetching trie nodes from the database during execution.

Rationale

This pull request can enhance merkleization efficiency by approximately 56% for the BSC network.

Example

We separately tracked the time taken for inserting blocks, executing blocks, and calculating the state root during live sync. We will compare these metrics to gain insights into their performance.

BSC Test Result - Live sync 14K blocks, from 41550000 to 41564139.

  • Statistical Average
image
  • Scatter Plot for Execution Time
    image

  • Scatter Plot for State Root Calculation Time
    image

  • Scatter Plot for Total Time
    image

The Prefetch feature boosts state root calculation efficiency during BSC live sync without compromising block execution efficiency. This leads to a 56% decrease in state root calculation time and a 29% reduction in total block insertion time.

opBNB Test Result - Live sync 14K blocks, from 33180000 to 33194139.

  • Statistical Average
image
  • Scatter Plot for Execution Time
    image

  • Scatter Plot for State Root Calculation Time
    image

  • Scatter Plot for Total Time
    image

In the case of opBNB, the execution time, state root calculation time, and total time for block insertion are all relatively small. Prefetching optimization doesn't show clear benefits for opBNB. This could be due to the small world state tree of opBNB. When opBNB runs on a machine with 128GB of memory, most trie nodes are already in memory, making prefetch optimization ineffective.

Changes

Notable changes:

  • Add trie prefetch when executing blocks

Potential Impacts

  • NA

@bnb-chain bnb-chain deleted a comment from realuncle Jul 11, 2024
@gakonst
Copy link
Contributor

gakonst commented Jul 17, 2024

Have you guys benchmarked this work yet? Pretty exciting and stuff we've talked about before, keen to see how well it does as state root is by far the bottleneck...

@keefel
Copy link
Contributor Author

keefel commented Jul 18, 2024

Have you guys benchmarked this work yet? Pretty exciting and stuff we've talked about before, keen to see how well it does as state root is by far the bottleneck...

Thank you for being so interested. We are currently conducting performance tests and will soon release the relevant data publicly.

@unclezoro unclezoro changed the title feat: add trie prefetch when executing blocks [WIP]feat: add trie prefetch when executing blocks Aug 30, 2024
@keefel keefel changed the title [WIP]feat: add trie prefetch when executing blocks [R4R]feat: add trie prefetch when executing blocks Aug 30, 2024
Makefile Outdated Show resolved Hide resolved
@keefel keefel changed the title [R4R]feat: add trie prefetch when executing blocks feat: add trie prefetch when executing blocks Sep 3, 2024
@keefel keefel added this pull request to the merge queue Sep 3, 2024
Merged via the queue into bnb-chain:develop with commit 29a6048 Sep 3, 2024
34 checks passed
This was referenced Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants