Skip to content

Commit 3e78eda

Browse files
mpauluccijrchatruc
authored andcommitted
refactor(core): cleanup import blocks bench code (#2631)
**Description** - Moved import blocks benchmark from the top folder to /cmd/ethrex - Updated evm in benchmark to use the default one - Renamed generic `criterion_benchmark` to `import_block_benchmark` - Renamed confusing `genesis-l2-ci.json` to `genesis-perf-ci.json` since it's not really related to l2. - Removed deprecated flamegraph script --------- Co-authored-by: Javier Chatruc <jrchatruc@gmail.com>
1 parent 901fe01 commit 3e78eda

File tree

11 files changed

+26
-75
lines changed

11 files changed

+26
-75
lines changed

.github/workflows/main_flamegraph_report.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ jobs:
237237
cargo build --release --bin ethrex --features dev
238238
CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph -c "record -o perf.data -F997 --call-graph dwarf,16384 -g" \
239239
--bin ethrex --release --features dev -- \
240-
--dev --network /home/runner/work/ethrex/ethrex/test_data/genesis-l2-ci.json --http.port 1729 >/dev/null &
240+
--dev --network /home/runner/work/ethrex/ethrex/test_data/genesis-perf-ci.json --http.port 1729 >/dev/null &
241241
sleep 10
242242
echo "Executing load test..."
243243
bash /home/runner/work/ethrex/ethrex/.github/scripts/flamegraph_watcher.sh &&
@@ -352,7 +352,7 @@ jobs:
352352
rm -rf target/profiling/reth
353353
cargo build --bin reth --profile profiling
354354
CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph -c "record -o perf.data -F997 --call-graph dwarf,16384 -g" --bin reth --profile profiling -- \
355-
node --chain /home/runner/work/ethrex/ethrex/test_data/genesis-l2-ci.json --dev \
355+
node --chain /home/runner/work/ethrex/ethrex/test_data/genesis-perf-ci.json --dev \
356356
--dev.block-time 1000ms --http.port 1729 --txpool.max-pending-txns 100000000 --txpool.max-new-txns 1000000000 \
357357
--txpool.pending-max-count 100000000 --txpool.pending-max-size 10000000000 --txpool.basefee-max-count 100000000000 \
358358
--txpool.basefee-max-size 1000000000000 --txpool.queued-max-count 1000000000 >/dev/null &

.github/workflows/main_perf_benchmark.yml renamed to .github/workflows/main_perf_blocks_exec.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Install gnuplot
2626
run: sudo apt-get install -y gnuplot
2727
- name: Run benchmark
28-
run: cd cmd/ethrex && cargo bench --bench criterion_benchmark -- --output-format bencher |sed 2d | tee output.txt
28+
run: cd cmd/ethrex && cargo bench --bench import_blocks_benchmark -- --output-format bencher |sed 2d | tee output.txt
2929
- name: Store benchmark result
3030
uses: benchmark-action/github-action-benchmark@v1
3131
with:

.github/workflows/pr_perf_blocks_exec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
BINS="base,head"
8484
hyperfine --setup "./bin/ethrex-base removedb" -w 5 -N -r 10 --show-output --export-markdown "bench_pr_comparison.md" \
8585
-L bin "$BINS" -n "{bin}" \
86-
"./bin/ethrex-{bin} --network test_data/genesis-l2-ci.json --force import ./test_data/l2-1k-erc20.rlp --removedb"
86+
"./bin/ethrex-{bin} --network test_data/genesis-perf-ci.json --force import ./test_data/l2-1k-erc20.rlp --removedb"
8787
echo -e "## Benchmark Block Execution Results Comparison Against Main\n\n$(cat bench_pr_comparison.md)" > bench_pr_comparison.md
8888
- name: Upload PR results
8989
uses: actions/upload-artifact@v4

Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,5 @@ load-test-io:
176176
rm-test-db: ## 🛑 Removes the DB used by the ethrex client used for testing
177177
sudo cargo run --release --bin ethrex -- removedb --force --datadir test_ethrex
178178

179-
flamegraph: ## 🚧 Runs a load-test. Run make start-node-with-flamegraph and in a new terminal make flamegraph
180-
sudo bash bench/scripts/flamegraph.sh
181-
182179
test_data/ERC20/ERC20.bin: ## 🔨 Build the ERC20 contract for the load test
183180
solc ./test_data/ERC20.sol -o $@

bench/scripts/flamegraph.sh

Lines changed: 0 additions & 41 deletions
This file was deleted.

cmd/ethrex/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ path = "./lib.rs"
5555
default = ["libmdbx", "c-kzg", "blst"]
5656
dev = ["dep:ethrex-dev"]
5757
c-kzg = [
58-
"ethrex-vm/c-kzg",
59-
"ethrex-common/c-kzg",
60-
"ethrex-blockchain/c-kzg",
61-
"ethrex-p2p/c-kzg",
58+
"ethrex-vm/c-kzg",
59+
"ethrex-common/c-kzg",
60+
"ethrex-blockchain/c-kzg",
61+
"ethrex-p2p/c-kzg",
6262
]
6363
metrics = ["ethrex-blockchain/metrics"]
6464
libmdbx = ["ethrex-storage/libmdbx"]
@@ -81,8 +81,8 @@ based = ["l2", "ethrex-rpc/based"]
8181
criterion = { version = "0.5.1", features = ["html_reports"] }
8282

8383
[[bench]]
84-
path = "../../bench/criterion_benchmark.rs"
85-
name = "criterion_benchmark"
84+
path = "./bench/import_blocks_benchmark.rs"
85+
name = "import_blocks_benchmark"
8686
harness = false
8787

8888
[build-dependencies]
Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
1-
#![allow(unused)]
2-
3-
use criterion::{black_box, criterion_group, criterion_main, Criterion};
1+
use criterion::{criterion_group, criterion_main, Criterion};
42
use ethrex::{
53
cli::{import_blocks, remove_db},
6-
initializers::{init_blockchain, init_store},
74
utils::set_datadir,
85
DEFAULT_DATADIR,
96
};
10-
use ethrex_p2p::network;
11-
use std::{env::set_current_dir, str::FromStr, thread, time::Duration};
12-
use tracing_subscriber::{filter::Directive, EnvFilter, FmtSubscriber};
7+
use ethrex_vm::EvmEngine;
138

149
#[inline]
1510
fn block_import() {
1611
let data_dir = DEFAULT_DATADIR;
1712
set_datadir(data_dir);
1813
remove_db(data_dir, true);
1914

20-
let evm_engine = "revm".to_owned().try_into().unwrap();
15+
let evm_engine = EvmEngine::default();
2116

22-
let network = "../../test_data/genesis-l2-ci.json";
17+
let network = "../../test_data/genesis-perf-ci.json";
2318

2419
let rt = tokio::runtime::Runtime::new().unwrap();
2520
rt.block_on(import_blocks(
@@ -30,12 +25,12 @@ fn block_import() {
3025
));
3126
}
3227

33-
pub fn criterion_benchmark(c: &mut Criterion) {
28+
pub fn import_blocks_benchmark(c: &mut Criterion) {
3429
let mut group = c.benchmark_group("Block import");
3530
group.sample_size(10);
3631
group.bench_function("Block import ERC20 transfers", |b| b.iter(block_import));
3732
group.finish();
3833
}
3934

40-
criterion_group!(runner, criterion_benchmark);
35+
criterion_group!(runner, import_blocks_benchmark);
4136
criterion_main!(runner);

cmd/load_test/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ On some machines, this fixes the `ERROR axum::serve::listener: accept error: Too
3131
To run a load test, first run the node using a command like the following in the root folder:
3232

3333
```bash
34-
cargo run --bin ethrex --release --features dev -- --network test_data/genesis-l2-ci.json --dev
34+
cargo run --bin ethrex --release --features dev -- --network test_data/genesis-perf-ci.json --dev
3535
```
3636

3737
Genesis-l2-ci has many rich accounts and does not include the prague fork, which is important for dev mode until it's fixed.
@@ -73,39 +73,39 @@ Load tests are usually used to get performance metrics. We usually want to gener
7373
To produce a flamegraph, run the node in the following way.
7474

7575
```bash
76-
cargo flamegraph --root --bin ethrex --release --features dev -- --network test_data/genesis-l2-ci.json --dev
76+
cargo flamegraph --root --bin ethrex --release --features dev -- --network test_data/genesis-perf-ci.json --dev
7777
```
7878

7979
The "root" command is only needed for mac. It can be removed if running on linux.
8080

8181
For a samply report, run the following:
8282

8383
```bash
84-
samply record cargo run --bin ethrex --release --features dev -- --network test_data/genesis-l2-ci.json --dev
84+
samply record cargo run --bin ethrex --release --features dev -- --network test_data/genesis-perf-ci.json --dev
8585
```
8686

8787
## Interacting with reth
8888

8989
The same load test can be run, the only difference is how you run the node:
9090

9191
```bash
92-
cargo run --release -- node --chain <path_to_ethrex>/test_data/genesis-l2-ci.json --dev --dev.block-time 5000ms --http.port 8545 --txpool.max-pending-txns 100000000 --txpool.max-new-txns 1000000000 --txpool.pending-max-count 100000000 --txpool.pending-max-size 10000000000 --txpool.basefee-max-count 100000000000 --txpool.basefee-max-size 1000000000000 --txpool.queued-max-count 1000000000
92+
cargo run --release -- node --chain <path_to_ethrex>/test_data/genesis-perf-ci.json --dev --dev.block-time 5000ms --http.port 8545 --txpool.max-pending-txns 100000000 --txpool.max-new-txns 1000000000 --txpool.pending-max-count 100000000 --txpool.pending-max-size 10000000000 --txpool.basefee-max-count 100000000000 --txpool.basefee-max-size 1000000000000 --txpool.queued-max-count 1000000000
9393
```
9494

9595
All of the txpool parameters are to make sure that it doesn't discard transactions sent by the load test. Trhoughput measurements in the logs are typically near 1Gigagas/second. To remove the database before getting measurements again:
9696

9797
```bash
98-
cargo run --release -- db --chain <path_to_ethrex>/test_data/genesis-l2-ci.json drop -f
98+
cargo run --release -- db --chain <path_to_ethrex>/test_data/genesis-perf-ci.json drop -f
9999
```
100100

101101
To get a flamegraph of its execution, run with the same parameters, just replace `cargo run --release` with `cargo flamegraph --bin reth --profiling`:
102102

103103
```bash
104-
cargo flamegraph --bin reth --root --profiling -- node --chain ~/workspace/ethrex/test_data/genesis-l2-ci.json --dev --dev.block-time 5000ms --http.port 8545 --txpool.max-pending-txns 100000000 --txpool.max-new-txns 1000000000 --txpool.pending-max-count 100000000 --txpool.pending-max-size 10000000000 --txpool.basefee-max-count 100000000000 --txpool.basefee-max-size 1000000000000 --txpool.queued-max-count 1000000000
104+
cargo flamegraph --bin reth --root --profiling -- node --chain ~/workspace/ethrex/test_data/genesis-perf-ci.json --dev --dev.block-time 5000ms --http.port 8545 --txpool.max-pending-txns 100000000 --txpool.max-new-txns 1000000000 --txpool.pending-max-count 100000000 --txpool.pending-max-size 10000000000 --txpool.basefee-max-count 100000000000 --txpool.basefee-max-size 1000000000000 --txpool.queued-max-count 1000000000
105105
```
106106

107107
For samply we want to directly execute the binary, so that it records the binary and not cargo itself:
108108

109109
```bash
110-
samply record ./target/profiling/reth node --chain ~/workspace/ethrex/test_data/genesis-l2-ci.json --dev --dev.block-time 5000ms --http.port 8545 --txpool.max-pending-txns 100000000 --txpool.max-new-txns 1000000000 --txpool.pending-max-count 100000000 --txpool.pending-max-size 10000000000 --txpool.basefee-max-count 100000000000 --txpool.basefee-max-size 1000000000000 --txpool.queued-max-count 1000000000
111-
```
110+
samply record ./target/profiling/reth node --chain ~/workspace/ethrex/test_data/genesis-perf-ci.json --dev --dev.block-time 5000ms --http.port 8545 --txpool.max-pending-txns 100000000 --txpool.max-new-txns 1000000000 --txpool.pending-max-count 100000000 --txpool.pending-max-size 10000000000 --txpool.basefee-max-count 100000000000 --txpool.basefee-max-size 1000000000000 --txpool.queued-max-count 1000000000
111+
```

crates/l2/prover/tests/perf_zkvm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ async fn test_performance_zkvm() {
3636
async fn setup() -> (ProgramInput, Block) {
3737
let path = Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../../../test_data"));
3838

39-
let genesis_file_path = path.join("genesis-l2-ci.json");
39+
let genesis_file_path = path.join("genesis-perf-ci.json");
4040
// l2-loadtest.rlp has blocks with many txs.
4141
let chain_file_path = path.join("l2-loadtest.rlp");
4242

crates/l2/utils/prover/save_state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ mod tests {
416416
let path = Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/../../test_data"));
417417

418418
let chain_file_path = path.join("l2-loadtest.rlp");
419-
let genesis_file_path = path.join("genesis-l2-ci.json");
419+
let genesis_file_path = path.join("genesis-perf-ci.json");
420420

421421
// Create an InMemory Store to later perform an execute_block so we can have the Vec<AccountUpdate>.
422422
let in_memory_db =

0 commit comments

Comments
 (0)