Skip to content

Commit

Permalink
feat: add benchmark for decoder block processing
Browse files Browse the repository at this point in the history
  • Loading branch information
Nashtare committed Jun 11, 2024
1 parent 3a5075e commit 3933635
Show file tree
Hide file tree
Showing 3 changed files with 9,726 additions and 0 deletions.
6 changes: 6 additions & 0 deletions trace_decoder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,10 @@ mpt_trie = { version = "0.2.1", path = "../mpt_trie" }
evm_arithmetization = { version = "0.1.3", path = "../evm_arithmetization" }

[dev-dependencies]
criterion = "0.5.1"
pretty_env_logger = "0.5.0"
serde_json = { workspace = true }

[[bench]]
name = "block_processing"
harness = false
9,671 changes: 9,671 additions & 0 deletions trace_decoder/benches/block_input.json

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions trace_decoder/benches/block_processing.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//! Benchmarks the processing by the decoder of a block witness obtained from a
//! node into a sequence of prover inputs ready to be sent to a prover.
//!
//! The block being processed here is the 19240650th Ethereum block
//! (<https://etherscan.io/block/19240650>) containing 201 transactions and 16 withdrawals.
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
use serde::{Deserialize, Serialize};
use trace_decoder::{
processed_block_trace::ProcessingMeta,
trace_protocol::BlockTrace,
types::{CodeHash, OtherBlockData},
};

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ProverInput {
pub block_trace: BlockTrace,
pub other_data: OtherBlockData,
}

fn resolve_code_hash_fn(_: &CodeHash) -> Vec<u8> {
todo!()
}

fn criterion_benchmark(c: &mut Criterion) {
let bytes = std::fs::read("benches/block_input.json").unwrap();
let prover_input: ProverInput = serde_json::from_slice(&bytes).unwrap();

c.bench_function("Block 19240650 processing", |b| {
b.iter_batched(
|| prover_input.clone(),
|pi| {
pi.block_trace
.into_txn_proof_gen_ir(
&ProcessingMeta::new(resolve_code_hash_fn),
prover_input.other_data.clone(),
)
.unwrap()
},
BatchSize::LargeInput,
)
});
}

criterion_group!(
name = benches;
config = Criterion::default().sample_size(10);
targets = criterion_benchmark);
criterion_main!(benches);

0 comments on commit 3933635

Please sign in to comment.