Skip to content

perf(l1, l2): pipeline VM merklelization#5084

Merged
jrchatruc merged 70 commits intomainfrom
pipeline_vm_merkle
Nov 1, 2025
Merged

perf(l1, l2): pipeline VM merklelization#5084
jrchatruc merged 70 commits intomainfrom
pipeline_vm_merkle

Conversation

@pablodeymo
Copy link
Copy Markdown
Contributor

Motivation

We want to parallelize VM execution and merkelization.

Description

Closes #issue_number

Copy link
Copy Markdown
Contributor

@Oppen Oppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not merge this until:

  1. It has a proper implementation that does not duplicate half the codebase;
  2. It has proper documentation: text in docs, reliable comments, and those comments correctly linking to the text docs.

As it is now, this is horrible and brittle.

@github-actions
Copy link
Copy Markdown

Benchmark for c40e7f5

Click to view benchmark
Test Base PR %
Trie/cita-trie insert 10k 35.6±0.98ms 36.7±1.82ms +3.09%
Trie/cita-trie insert 1k 3.5±0.01ms 3.6±0.02ms +2.86%
Trie/ethrex-trie insert 10k 31.1±0.35ms 32.4±0.83ms +4.18%
Trie/ethrex-trie insert 1k 5.3±0.06ms 2.8±0.06ms -47.17%

&& !self.pending_removal.contains(&path)
&& self.db().flatkeyvalue_computed(path.clone())
{
if pathrlp.len() == 32 && !self.dirty && self.db().flatkeyvalue_computed(path.clone()) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit extreme and might introduce noticeable overhead due to always traversing the trie during merkleization, never taking advantage of the flat key-value.

@github-actions
Copy link
Copy Markdown

Benchmark for f94898f

Click to view benchmark
Test Base PR %
Trie/cita-trie insert 10k 41.6±1.56ms 33.8±1.02ms -18.75%
Trie/cita-trie insert 1k 3.6±0.02ms 3.6±0.17ms 0.00%
Trie/ethrex-trie insert 10k 33.4±0.75ms 32.9±1.31ms -1.50%
Trie/ethrex-trie insert 1k 5.3±0.09ms 2.8±0.01ms -47.17%

) -> FxHashMap<Address, Account> {
// Default state has sender with some balance to send Tx, it can be overwritten though.
let mut initial_state = BTreeMap::from([(
let mut initial_state = FxHashMap::from_iter(vec![(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let mut initial_state = FxHashMap::from_iter(vec![(
let mut initial_state = FxHashMap::from_iter([(

Ok(account_updates)
}

pub fn get_state_transitions_tx(&mut self) -> Result<Vec<AccountUpdate>, VMError> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a function in utils that might do this work for us.

@github-actions
Copy link
Copy Markdown

Benchmark for 7a9142f

Click to view benchmark
Test Base PR %
Trie/cita-trie insert 10k 34.9±0.63ms 40.4±2.67ms +15.76%
Trie/cita-trie insert 1k 3.5±0.02ms 3.6±0.20ms +2.86%
Trie/ethrex-trie insert 10k 31.0±0.09ms 32.0±1.39ms +3.23%
Trie/ethrex-trie insert 1k 5.3±0.07ms 2.8±0.03ms -47.17%

@github-actions
Copy link
Copy Markdown

Benchmark for 57ef91a

Click to view benchmark
Test Base PR %
Trie/cita-trie insert 10k 35.1±1.01ms 34.5±0.59ms -1.71%
Trie/cita-trie insert 1k 3.5±0.02ms 3.6±0.16ms +2.86%
Trie/ethrex-trie insert 10k 31.3±0.55ms 31.1±0.73ms -0.64%
Trie/ethrex-trie insert 1k 5.3±0.17ms 2.8±0.02ms -47.17%

@jrchatruc jrchatruc enabled auto-merge October 31, 2025 23:01
@jrchatruc jrchatruc added this pull request to the merge queue Oct 31, 2025
@jrchatruc jrchatruc removed this pull request from the merge queue due to the queue being cleared Nov 1, 2025
@jrchatruc jrchatruc enabled auto-merge November 1, 2025 01:14
@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 1, 2025

Benchmark for ea7fe5a

Click to view benchmark
Test Base PR %
Trie/cita-trie insert 10k 35.5±0.93ms 35.6±1.00ms +0.28%
Trie/cita-trie insert 1k 3.6±0.02ms 3.6±0.21ms 0.00%
Trie/ethrex-trie insert 10k 31.8±0.56ms 31.3±0.67ms -1.57%
Trie/ethrex-trie insert 1k 5.4±0.09ms 2.8±0.08ms -48.15%

@jrchatruc jrchatruc added this pull request to the merge queue Nov 1, 2025
Merged via the queue into main with commit 6c7cb35 Nov 1, 2025
53 checks passed
@jrchatruc jrchatruc deleted the pipeline_vm_merkle branch November 1, 2025 01:52
@github-project-automation github-project-automation bot moved this from Todo to Done in ethrex_performance Nov 1, 2025
@github-project-automation github-project-automation bot moved this from In Review to Done in ethrex_l1 Nov 1, 2025
@github-project-automation github-project-automation bot moved this to Done in ethrex_l2 Nov 1, 2025
github-merge-queue bot pushed a commit that referenced this pull request Nov 6, 2025
**Motivation**

The `Execution Breakdown` pie chart was broken after #5084

**Description**

This PR is a quick fix of the pie chart, the idea is to have a complete
rework in a follow-up PR but for now it serves to avoid showing
misleading info, now the chart effectively measures
`execute_block_pipeline` + the sync store step after it:
- Now that Block Execution and Merkleization are part of
`execute_block_pipeline` we removed the Trie update measure
(merkleization) from the chart because it will be happening concurrently
with execution.
- We added a new `Other (pipeline diff)` measure, that takes the whole
`execute_block_pipeline` and removes the execution from it (aka the
missing merkleization measure).

| Main | This PR |
| ---- | ---- |
| <img width="741" height="427" alt="image"
src="https://github.com/user-attachments/assets/3025cd92-6355-4365-92de-f9eb4039d97e"
/> | <img width="744" height="465" alt="image"
src="https://github.com/user-attachments/assets/7e2f7784-0666-4984-aef8-cd39e10f6ca7"
/> |
xqft pushed a commit that referenced this pull request Nov 11, 2025
**Motivation**

We want to parallelize VM execution and merkelization.

**Description**

<!-- A clear and concise general description of the changes this PR
introduces -->

<!-- Link to issues: Resolves #111, Resolves #222 -->

Closes #issue_number

---------

Co-authored-by: Mario Rugiero <mrugiero@gmail.com>
Co-authored-by: Lucas Fiegl <iovoid@users.noreply.github.com>
Co-authored-by: Javier Rodríguez Chatruc <49622509+jrchatruc@users.noreply.github.com>
Co-authored-by: Javier Chatruc <jrchatruc@gmail.com>
xqft pushed a commit that referenced this pull request Nov 11, 2025
**Motivation**

The `Execution Breakdown` pie chart was broken after #5084

**Description**

This PR is a quick fix of the pie chart, the idea is to have a complete
rework in a follow-up PR but for now it serves to avoid showing
misleading info, now the chart effectively measures
`execute_block_pipeline` + the sync store step after it:
- Now that Block Execution and Merkleization are part of
`execute_block_pipeline` we removed the Trie update measure
(merkleization) from the chart because it will be happening concurrently
with execution.
- We added a new `Other (pipeline diff)` measure, that takes the whole
`execute_block_pipeline` and removes the execution from it (aka the
missing merkleization measure).

| Main | This PR |
| ---- | ---- |
| <img width="741" height="427" alt="image"
src="https://github.com/user-attachments/assets/3025cd92-6355-4365-92de-f9eb4039d97e"
/> | <img width="744" height="465" alt="image"
src="https://github.com/user-attachments/assets/7e2f7784-0666-4984-aef8-cd39e10f6ca7"
/> |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L1 Ethereum client L2 Rollup client performance Block execution throughput and performance in general

Projects

Status: Done
Status: Done
Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants