From 5b3632d9d945aa837001c44c11e5a950ecdbf6e6 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Sat, 7 May 2022 03:18:59 +0000 Subject: [PATCH] zcash_proofs: Add flamegraph profiling to Sapling Spend benchmark --- zcash_proofs/Cargo.toml | 3 +++ zcash_proofs/benches/sapling.rs | 19 ++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/zcash_proofs/Cargo.toml b/zcash_proofs/Cargo.toml index 299d6b1e9..8289b2bf9 100644 --- a/zcash_proofs/Cargo.toml +++ b/zcash_proofs/Cargo.toml @@ -33,6 +33,9 @@ zcash_primitives = { version = "0.5", path = "../zcash_primitives" } criterion = "0.3" rand_xorshift = "0.3" +[target.'cfg(unix)'.dev-dependencies] +pprof = { version = "0.8", features = ["criterion", "flamegraph"] } # MSRV 1.56 + [features] default = ["local-prover", "multicore"] bundled-prover = ["wagyu-zcash-parameters"] diff --git a/zcash_proofs/benches/sapling.rs b/zcash_proofs/benches/sapling.rs index 382563c25..cc9e77277 100644 --- a/zcash_proofs/benches/sapling.rs +++ b/zcash_proofs/benches/sapling.rs @@ -11,6 +11,9 @@ use rand_xorshift::XorShiftRng; use zcash_primitives::sapling::{Diversifier, ProofGenerationKey, ValueCommitment}; use zcash_proofs::circuit::sapling::Spend; +#[cfg(unix)] +use pprof::criterion::{Output, PProfProfiler}; + const TREE_DEPTH: usize = 32; fn criterion_benchmark(c: &mut Criterion) { @@ -33,7 +36,7 @@ fn criterion_benchmark(c: &mut Criterion) { ) .unwrap(); - c.bench_function("sapling", |b| { + c.bench_function("sapling-spend-prove", |b| { let value_commitment = ValueCommitment { value: 1, randomness: jubjub::Fr::random(&mut rng), @@ -85,8 +88,18 @@ fn criterion_benchmark(c: &mut Criterion) { }); } -criterion_group!( +#[cfg(unix)] +criterion_group! { + name = benches; + config = Criterion::default() + .sample_size(10) + .with_profiler(PProfProfiler::new(100, Output::Flamegraph(None))); + targets = criterion_benchmark +} +#[cfg(windows)] +criterion_group! { name = benches; config = Criterion::default().sample_size(10); - targets = criterion_benchmark); + targets = criterion_benchmark +} criterion_main!(benches);