Skip to content
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

test(bench): Playing with flamegraph generation [wip] #8

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
);
Loading