Browse Source

Fix benches so it varies the number of constraints in the augmented circuit in powers of 2 (#97)

* vary the number of constraints in the step circuit

* use a different starting state
main
Srinath Setty 2 years ago
committed by GitHub
parent
commit
c6fa4d44eb
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 19 deletions
  1. +12
    -9
      benches/compressed-snark.rs
  2. +14
    -10
      benches/recursive-snark.rs

+ 12
- 9
benches/compressed-snark.rs

@ -30,10 +30,13 @@ criterion_main!(compressed_snark);
fn bench_compressed_snark(c: &mut Criterion) { fn bench_compressed_snark(c: &mut Criterion) {
let num_samples = 10; let num_samples = 10;
let num_cons_verifier_circuit_primary = 20584;
// we vary the number of constraints in the step circuit // we vary the number of constraints in the step circuit
for &log_num_cons_in_step_circuit in [0, 14, 15, 16, 17, 18, 19, 20].iter() {
let num_cons = 1 << log_num_cons_in_step_circuit;
for &num_cons_in_augmented_circuit in
[20584, 32768, 65536, 131072, 262144, 524288, 1048576].iter()
{
// number of constraints in the step circuit
let num_cons = num_cons_in_augmented_circuit - num_cons_verifier_circuit_primary;
let mut group = c.benchmark_group(format!("CompressedSNARK-StepCircuitSize-{}", num_cons)); let mut group = c.benchmark_group(format!("CompressedSNARK-StepCircuitSize-{}", num_cons));
group.sample_size(num_samples); group.sample_size(num_samples);
@ -54,8 +57,8 @@ fn bench_compressed_snark(c: &mut Criterion) {
recursive_snark, recursive_snark,
NonTrivialTestCircuit::new(num_cons), NonTrivialTestCircuit::new(num_cons),
TrivialTestCircuit::default(), TrivialTestCircuit::default(),
<G1 as Group>::Scalar::one(),
<G2 as Group>::Scalar::one(),
<G1 as Group>::Scalar::from(2u64),
<G2 as Group>::Scalar::from(2u64),
); );
assert!(res.is_ok()); assert!(res.is_ok());
let recursive_snark_unwrapped = res.unwrap(); let recursive_snark_unwrapped = res.unwrap();
@ -64,8 +67,8 @@ fn bench_compressed_snark(c: &mut Criterion) {
let res = recursive_snark_unwrapped.verify( let res = recursive_snark_unwrapped.verify(
&pp, &pp,
i + 1, i + 1,
<G1 as Group>::Scalar::one(),
<G2 as Group>::Scalar::one(),
<G1 as Group>::Scalar::from(2u64),
<G2 as Group>::Scalar::from(2u64),
); );
assert!(res.is_ok()); assert!(res.is_ok());
@ -95,8 +98,8 @@ fn bench_compressed_snark(c: &mut Criterion) {
.verify( .verify(
black_box(&pp), black_box(&pp),
black_box(num_steps), black_box(num_steps),
black_box(<G1 as Group>::Scalar::one()),
black_box(<G2 as Group>::Scalar::one()),
black_box(<G1 as Group>::Scalar::from(2u64)),
black_box(<G2 as Group>::Scalar::from(2u64)),
) )
.is_ok()); .is_ok());
}) })

+ 14
- 10
benches/recursive-snark.rs

@ -27,9 +27,13 @@ targets = bench_recursive_snark
criterion_main!(recursive_snark); criterion_main!(recursive_snark);
fn bench_recursive_snark(c: &mut Criterion) { fn bench_recursive_snark(c: &mut Criterion) {
let num_cons_verifier_circuit_primary = 20584;
// we vary the number of constraints in the step circuit // we vary the number of constraints in the step circuit
for &log_num_cons_in_step_circuit in [0, 14, 15, 16, 17, 18, 19, 20].iter() {
let num_cons = 1 << log_num_cons_in_step_circuit;
for &num_cons_in_augmented_circuit in
[20584, 32768, 65536, 131072, 262144, 524288, 1048576].iter()
{
// number of constraints in the step circuit
let num_cons = num_cons_in_augmented_circuit - num_cons_verifier_circuit_primary;
let mut group = c.benchmark_group(format!("RecursiveSNARK-StepCircuitSize-{}", num_cons)); let mut group = c.benchmark_group(format!("RecursiveSNARK-StepCircuitSize-{}", num_cons));
group.sample_size(10); group.sample_size(10);
@ -53,8 +57,8 @@ fn bench_recursive_snark(c: &mut Criterion) {
recursive_snark, recursive_snark,
NonTrivialTestCircuit::new(num_cons), NonTrivialTestCircuit::new(num_cons),
TrivialTestCircuit::default(), TrivialTestCircuit::default(),
<G1 as Group>::Scalar::one(),
<G2 as Group>::Scalar::one(),
<G1 as Group>::Scalar::from(2u64),
<G2 as Group>::Scalar::from(2u64),
); );
assert!(res.is_ok()); assert!(res.is_ok());
let recursive_snark_unwrapped = res.unwrap(); let recursive_snark_unwrapped = res.unwrap();
@ -63,8 +67,8 @@ fn bench_recursive_snark(c: &mut Criterion) {
let res = recursive_snark_unwrapped.verify( let res = recursive_snark_unwrapped.verify(
&pp, &pp,
i + 1, i + 1,
<G1 as Group>::Scalar::one(),
<G2 as Group>::Scalar::one(),
<G1 as Group>::Scalar::from(2u64),
<G2 as Group>::Scalar::from(2u64),
); );
assert!(res.is_ok()); assert!(res.is_ok());
@ -80,8 +84,8 @@ fn bench_recursive_snark(c: &mut Criterion) {
black_box(recursive_snark.clone()), black_box(recursive_snark.clone()),
black_box(NonTrivialTestCircuit::new(num_cons)), black_box(NonTrivialTestCircuit::new(num_cons)),
black_box(TrivialTestCircuit::default()), black_box(TrivialTestCircuit::default()),
black_box(<G1 as Group>::Scalar::one()),
black_box(<G2 as Group>::Scalar::one()),
black_box(<G1 as Group>::Scalar::from(2u64)),
black_box(<G2 as Group>::Scalar::from(2u64)),
) )
.is_ok()); .is_ok());
}) })
@ -96,8 +100,8 @@ fn bench_recursive_snark(c: &mut Criterion) {
.verify( .verify(
black_box(&pp), black_box(&pp),
black_box(num_warmup_steps), black_box(num_warmup_steps),
black_box(<G1 as Group>::Scalar::one()),
black_box(<G2 as Group>::Scalar::one()),
black_box(<G1 as Group>::Scalar::from(2u64)),
black_box(<G2 as Group>::Scalar::from(2u64)),
) )
.is_ok()); .is_ok());
}); });

Loading…
Cancel
Save