-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: optimize poseidon2 implementation (#4807)
# Description ## Problem\* Resolves <!-- Link to GitHub Issue --> ## Summary\* This PR removes the usage of a `BigUint` from the poseidon2 solver. I've also wrapped all of the config in a `lazy_static` to avoid having to re-instantiate it each time. ## Additional Context ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
- Loading branch information
1 parent
645dba1
commit 0adeb08
Showing
5 changed files
with
494 additions
and
938 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use std::{hint::black_box, time::Duration}; | ||
|
||
use acir::FieldElement; | ||
use bn254_blackbox_solver::poseidon2_permutation; | ||
|
||
use pprof::criterion::{Output, PProfProfiler}; | ||
|
||
fn bench_poseidon2(c: &mut Criterion) { | ||
let inputs = [FieldElement::zero(); 4]; | ||
|
||
c.bench_function("poseidon2", |b| b.iter(|| poseidon2_permutation(black_box(&inputs), 4))); | ||
} | ||
|
||
criterion_group!( | ||
name = benches; | ||
config = Criterion::default().sample_size(40).measurement_time(Duration::from_secs(20)).with_profiler(PProfProfiler::new(100, Output::Flamegraph(None))); | ||
targets = bench_poseidon2 | ||
); | ||
|
||
criterion_main!(benches); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.