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

Add Nova Public Parameter benchmark for SDK #267

Merged
merged 1 commit into from
Aug 21, 2024
Merged
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
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,13 @@ jobs:
run: |
cargo bench --bench riscv_machine

bench-nova-public-params:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not also benchmark the provers themselves?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. I tried, criterion need 10 samples at least, one prover run on CI takes 4-6 minutes, which lead to at least 40 to 60 minutes to benchmark Prover.
I have plan to move all CI tasks, including benchmark prover to self-host Github Action in near future.

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

4 changes: 4 additions & 0 deletions nova-benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 36 additions & 0 deletions nova-benches/benches/nova_public_parameter_generation.rs
Original file line number Diff line number Diff line change
@@ -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<ark_pallas::Projective>;
type C2 = PedersenCommitment<ark_vesta::Projective>;

fn nova_public_parameter_generation() {
let step_circuit = NonTrivialTestCircuit::new(0);
PublicParams::<G1, G2, C1, C2, PoseidonSponge<CF>, NonTrivialTestCircuit<CF>>::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);
1 change: 1 addition & 0 deletions nova-benches/benches/shared/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use ark_relations::r1cs::{ConstraintSystemRef, SynthesisError};
use nexus_nova::StepCircuit;
use std::marker::PhantomData;

#[allow(dead_code)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be dead code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a shared code, it is used in other benches, however I don't use the NUM_WARMUP_STEPS in my code, so I turn off the clippy warning in compilation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True I guess it is dead for that individual build... I mean it's all test code so I guess that's fine...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coincidently, the value of NUM_WARMUP_STEPS is 10, the minimum I need in criterion sample size is 10, I can plug in this value in my code and get rid of the allow[dead_code], but the variable name doesn't quite describe what the situation.

pub const NUM_WARMUP_STEPS: usize = 10;

pub struct NonTrivialTestCircuit<F> {
Expand Down