Skip to content

Commit

Permalink
toying with flamegraph generation
Browse files Browse the repository at this point in the history
  • Loading branch information
metachris committed Jul 3, 2024
1 parent 27a8867 commit 7688350
Show file tree
Hide file tree
Showing 5 changed files with 190 additions and 4 deletions.
152 changes: 150 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ fmt: ## Format the code
.PHONY: bench
bench: ## Run benchmarks
cargo bench --bench bench_main
# cargo bench --bench bench_main -- --verbose

.PHONY: bench-flamegraphs
bench-flamegraphs: ## Create flamegraphs for the benchmarks
cargo bench --bench bench_flamegraphs -- --profile-time 3

.PHONY: bench-report-open
bench-report-open: ## Open last benchmark report in the browser
Expand Down
5 changes: 5 additions & 0 deletions crates/rbuilder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ built = { version = "0.7.1", features = ["git2", "chrono"] }
[dev-dependencies]
tempfile = "3.8"
criterion = { version = "0.5.1", features = ["html_reports"] }
pprof = { version = "0.13.0", features = ["flamegraph", "criterion"] }

[[bench]]
name = "bench_main"
harness = false

[[bench]]
name = "bench_flamegraphs"
harness = false
7 changes: 7 additions & 0 deletions crates/rbuilder/benches/bench_flamegraphs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use criterion::criterion_main;

mod benchmarks;

criterion_main! {
benchmarks::mev_boost::serialization_flamegraph,
}
25 changes: 24 additions & 1 deletion crates/rbuilder/benches/benchmarks/mev_boost.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use criterion::{criterion_group, Criterion};
use pprof::criterion::{Output, PProfProfiler};

use ethereum_consensus::ssz::prelude::serialize;
use rbuilder::mev_boost::{
Expand Down Expand Up @@ -37,4 +38,26 @@ fn bench_mevboost_serialization(c: &mut Criterion) {
group.finish();
}

criterion_group!(serialization, bench_mevboost_serialization);
fn bench_mevboost_serialization_flamegraphs(c: &mut Criterion) {
let mut generator = TestDataGenerator::default();
c.bench_function("JSON", |b| {
b.iter_batched(
|| generator.create_deneb_submit_block_request(),
|b| {
serde_json::to_vec(&b).unwrap();
},
criterion::BatchSize::SmallInput,
);
});
}

criterion_group! {
name = serialization;
config = Criterion::default();
targets = bench_mevboost_serialization
}
criterion_group!(
name=serialization_flamegraph;
config = Criterion::default().with_profiler(PProfProfiler::new(100, Output::Flamegraph(None)));
targets = bench_mevboost_serialization_flamegraphs
);

0 comments on commit 7688350

Please sign in to comment.