Skip to content

perf(l2): avoid cloning all fields from ExecutionWitnessResult #3765

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

LeanSerra
Copy link
Contributor

@LeanSerra LeanSerra commented Jul 22, 2025

Motivation

When proving a large batch performance was being affected because we were cloning the entire ExecutionWitnessResult struct, this meant cloning all the BlockHeaders, Code and ChainConfig for every block.

Description

  • Wrap ExecutionWitnessResult in a struct that has an inner field Arc<Mutex> that implements VmDatabase trait, which can be cheaply cloned
  • Remove all the Arc<Mutex<>> from ExecutionWitnessResult, remove the VmDatabase trait implementation, remove the derive Clone.

Perf Metrics

command:

TRACE_FILE=output.json TRACE_SAMPLE_RATE=100 RUST_BACKTRACE=full cargo run --release --features "sp1,l2" -- execute batch --rpc-url RPC_URL --network 65536300 13

specs:

Model Identifier: MacBookAir10,1
Chip: Apple M1
Total Number of Cores: 8 (4 performance and 4 efficiency)
Memory: 16 GB
System Firmware Version: 11881.121.1
OS Loader Version: 11881.121.1

commits:
This branch (commit 16420ed)
Main (commit ce5c47d)

@LeanSerra LeanSerra self-assigned this Jul 22, 2025
@LeanSerra LeanSerra added L2 Rollup client prover L2 prover labels Jul 22, 2025
Copy link

Lines of code report

Total lines added: 177
Total lines removed: 81
Total lines changed: 258

Detailed view
+---------------------------------------------------------------+-------+------+
| File                                                          | Lines | Diff |
+---------------------------------------------------------------+-------+------+
| ethrex/cmd/ef_tests/state/parser.rs                           | 223   | -31  |
+---------------------------------------------------------------+-------+------+
| ethrex/cmd/ef_tests/state/runner/levm_runner.rs               | 429   | -1   |
+---------------------------------------------------------------+-------+------+
| ethrex/cmd/ethrex_replay/src/run.rs                           | 89    | +1   |
+---------------------------------------------------------------+-------+------+
| ethrex/crates/common/serde_utils.rs                           | 504   | -40  |
+---------------------------------------------------------------+-------+------+
| ethrex/crates/common/types/block.rs                           | 756   | +2   |
+---------------------------------------------------------------+-------+------+
| ethrex/crates/common/types/block_execution_witness.rs         | 485   | +64  |
+---------------------------------------------------------------+-------+------+
| ethrex/crates/l2/prover/zkvm/interface/src/execution.rs       | 364   | +15  |
+---------------------------------------------------------------+-------+------+
| ethrex/crates/l2/prover/zkvm/interface/src/io.rs              | 156   | +73  |
+---------------------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/clients/eth/mod.rs               | 1294  | +22  |
+---------------------------------------------------------------+-------+------+
| ethrex/crates/vm/backends/levm/mod.rs                         | 543   | -1   |
+---------------------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/bench/revm_comparison/src/levm_bench.rs | 70    | -1   |
+---------------------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/opcode_handlers/system.rs           | 824   | -4   |
+---------------------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/opcodes.rs                          | 499   | -1   |
+---------------------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/vm.rs                               | 218   | -1   |
+---------------------------------------------------------------+-------+------+
| ethrex/crates/vm/lib.rs                                       | 12    | -1   |
+---------------------------------------------------------------+-------+------+

@LeanSerra LeanSerra marked this pull request as ready for review July 22, 2025 14:59
@LeanSerra LeanSerra requested a review from a team as a code owner July 22, 2025 14:59
@LeanSerra LeanSerra moved this to In Review in ethrex_l2 Jul 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L2 Rollup client prover L2 prover
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

1 participant