Skip to content

Conversation

@fedacking
Copy link
Contributor

@fedacking fedacking commented Nov 6, 2025

Motivation

This pr aims to add a consistent command we can use to reproducible benchmark the speed of ethrex, without p2p and other concurrency problems enabled.

Description

  • Adds an import-bench subcommand to import blocks and execute them
  • Adds a makefile to autorun the bench tool
  • Added documentation to the tool

Example

python3 parse_bench.py 10 13
Blocks tested 1065
Mean ggas accross multiple runs: 0.14995899843505422
Mean ggas in run: 10 0.15196807511737107
Mean ggas in run: 11 0.15213427230046964
Mean ggas in run: 12 0.14577464788732383
Mean ggas spread across blocks: 0.004736776212832552

@github-actions github-actions bot added the L1 Ethereum client label Nov 6, 2025
@github-actions
Copy link

github-actions bot commented Nov 6, 2025

Lines of code report

Total lines added: 128
Total lines removed: 0
Total lines changed: 128

Detailed view
+--------------------------+-------+------+
| File                     | Lines | Diff |
+--------------------------+-------+------+
| ethrex/cmd/ethrex/cli.rs | 760   | +128 |
+--------------------------+-------+------+

@fedacking
Copy link
Contributor Author

We should print the actual execution time based without taking into account the background thread. Then we should print how much we're waiting. Print as "stall on background task"

@fedacking fedacking marked this pull request as ready for review November 7, 2025 18:06
@fedacking fedacking requested a review from a team as a code owner November 7, 2025 18:06
@ethrex-project-sync ethrex-project-sync bot moved this to In Review in ethrex_l1 Nov 7, 2025
This tool is used to benchmark the performance of **ethrex**.
We aim to execute the same set of blocks on the same hardware to ensure consistent
performance comparisons. Doing this on a running node is difficult because of variations
in hardware, peer count, and system load.
Copy link
Contributor

Choose a reason for hiding this comment

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

Mention block content, which is the biggest motivation for this tool.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in e50608d

Comment on lines 43 to 45
# Parameters:
# - BENCH_ID: Identifier for the log file, saved as bench-BENCH_ID.log
# - NETWORK: Network to access (e.g., hoodi, mainnet)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe bring the parameter list outside the code block

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in e50608d

@fedacking fedacking enabled auto-merge November 11, 2025 19:00
)
.await?;
}
Subcommand::ImportBench { path, removedb, l2 } => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should try to merge this with the import subcommand in the future.

3. Restart the node and let it advance by *X* additional blocks.
4. Stop the node again and run:
```bash
ethrex export --first <block_num> --last <block_num + X> ~/.local/share/ethrex_NETWORK_bench/chain.rlp
Copy link
Collaborator

@MegaRedHand MegaRedHand Nov 11, 2025

Choose a reason for hiding this comment

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

Unrelated to this PR, but I got an error "Too many open files" when exporting the chain. We probably need to add the "ulimit fix" to the export command.

Edit: nvm, I also got the error when running make run-bench. We should add that fix when opening the DB. This can be changed in another PR.

## View Output

You can view and compare benchmark results with:
`python3 parse_bench.py <bench_num_1> <bench_num_2>`
Copy link
Collaborator

Choose a reason for hiding this comment

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

Running this, I got a ModuleNotFoundError.

This comment was marked as resolved.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
`python3 parse_bench.py <bench_num_1> <bench_num_2>`
`python3 parse_bench.py <bench_id_start> <bench_id_end>`

We should also add an example, like we have in the PR description:

For example:

```text
# here we compare bench runs from 10 to 13 (non-inclusive)
$ python3 parse_bench.py 10 13
Blocks tested 1065
Mean ggas accross multiple runs: 0.14995899843505422
Mean ggas in run: 10 0.15196807511737107
Mean ggas in run: 11 0.15213427230046964
Mean ggas in run: 12 0.14577464788732383
Mean ggas spread across blocks: 0.004736776212832552
```

@fedacking fedacking added this pull request to the merge queue Nov 11, 2025
Merged via the queue into main with commit f27da23 Nov 11, 2025
48 checks passed
@fedacking fedacking deleted the feat/import-bench branch November 11, 2025 19:36
@github-project-automation github-project-automation bot moved this from In Review to Done in ethrex_l1 Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L1 Ethereum client

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants