From b7d140338d31ac71f30cc0ab780ac736412e7159 Mon Sep 17 00:00:00 2001 From: duc-nx <> Date: Wed, 21 Aug 2024 12:13:37 -0400 Subject: [PATCH] Add Nova Public Parameter benchmark for SDK Summary: Test Plan: --- .github/workflows/ci.yml | 10 ++++++ nova-benches/Cargo.toml | 4 +++ .../nova_public_parameter_generation.rs | 36 +++++++++++++++++++ nova-benches/benches/shared/mod.rs | 1 + 4 files changed, 51 insertions(+) create mode 100644 nova-benches/benches/nova_public_parameter_generation.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 556838ad..d615e1d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -90,3 +90,13 @@ jobs: run: | cargo bench --bench riscv_machine + bench-nova-public-params: + runs-on: ubuntu-latest + if: contains(github.event.pull_request.labels.*.name, 'benchmark') + steps: + - uses: actions/checkout@v4 + - name: Run benchmarks + run: | + cd nova-benches/ + cargo bench --bench nova_public_parameter_generation + diff --git a/nova-benches/Cargo.toml b/nova-benches/Cargo.toml index f5c66f7e..f1611ccb 100644 --- a/nova-benches/Cargo.toml +++ b/nova-benches/Cargo.toml @@ -27,6 +27,10 @@ parallel = ["nexus-nova/parallel"] name = "nova" harness = false +[[bench]] +name = "nova_public_parameter_generation" +harness = false + [[bench]] name = "hypernova" harness = false diff --git a/nova-benches/benches/nova_public_parameter_generation.rs b/nova-benches/benches/nova_public_parameter_generation.rs new file mode 100644 index 00000000..04da013b --- /dev/null +++ b/nova-benches/benches/nova_public_parameter_generation.rs @@ -0,0 +1,36 @@ +use ark_crypto_primitives::sponge::poseidon::PoseidonSponge; +use ark_pallas::{Fr as CF, PallasConfig as G1}; +use ark_vesta::VestaConfig as G2; +use criterion::{criterion_group, criterion_main, Criterion}; +use nexus_nova::{nova::sequential::PublicParams, pedersen::PedersenCommitment, poseidon_config}; + +mod shared; +use shared::NonTrivialTestCircuit; + +type C1 = PedersenCommitment; +type C2 = PedersenCommitment; + +fn nova_public_parameter_generation() { + let step_circuit = NonTrivialTestCircuit::new(0); + PublicParams::, NonTrivialTestCircuit>::setup( + poseidon_config(), + &step_circuit, + &(), + &(), + ) + .unwrap(); +} + +fn bench_nova_public_parameter(c: &mut Criterion) { + c.bench_function("nova_public_parameter", |b| { + b.iter(nova_public_parameter_generation) + }); +} + +criterion_group! { + name = benches; + config = Criterion::default().significance_level(0.1).sample_size(10); + targets = bench_nova_public_parameter +} + +criterion_main!(benches); diff --git a/nova-benches/benches/shared/mod.rs b/nova-benches/benches/shared/mod.rs index 3595b968..37bd2b24 100644 --- a/nova-benches/benches/shared/mod.rs +++ b/nova-benches/benches/shared/mod.rs @@ -4,6 +4,7 @@ use ark_relations::r1cs::{ConstraintSystemRef, SynthesisError}; use nexus_nova::StepCircuit; use std::marker::PhantomData; +#[allow(dead_code)] pub const NUM_WARMUP_STEPS: usize = 10; pub struct NonTrivialTestCircuit {