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

Refactor BaseFold hashing benchmark. #556

Merged
merged 3 commits into from
Nov 26, 2024
Merged
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
23 changes: 7 additions & 16 deletions mpcs/benches/hashing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,19 @@ use goldilocks::Goldilocks;
use mpcs::util::hash::{Digest, hash_two_digests};
use poseidon::poseidon_hash::PoseidonHash;

fn random_ceno_goldy() -> Goldilocks {
Goldilocks::random(&mut test_rng())
Copy link
Collaborator

Choose a reason for hiding this comment

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

A better style probably been changed to call test_rng() once and reused it instead of instantiate & drop immediately for every field element, which is very costly.

The good thing is it's put in bench "setup", at least not distorted benchmark results.

Not directly related to this PR, as it already there for long time. overall LGTM!

}
pub fn criterion_benchmark(c: &mut Criterion) {
let left = Digest(
vec![Goldilocks::random(&mut test_rng()); 4]
.try_into()
.unwrap(),
);
let right = Digest(
vec![Goldilocks::random(&mut test_rng()); 4]
.try_into()
.unwrap(),
);
let left = Digest(vec![random_ceno_goldy(); 4].try_into().unwrap());
let right = Digest(vec![random_ceno_goldy(); 4].try_into().unwrap());
c.bench_function("ceno hash 2 to 1", |bencher| {
bencher.iter(|| hash_two_digests(&left, &right))
});

let values = (0..60)
.map(|_| Goldilocks::random(&mut test_rng()))
.collect::<Vec<_>>();
let values = (0..60).map(|_| random_ceno_goldy()).collect::<Vec<_>>();
c.bench_function("ceno hash 60 to 1", |bencher| {
bencher.iter(|| {
PoseidonHash::hash_or_noop(&values);
})
bencher.iter(|| PoseidonHash::hash_or_noop(&values))
});
}

Expand Down