-
Notifications
You must be signed in to change notification settings - Fork 2
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
Adding telescope benchmarks #55
base: main
Are you sure you want to change the base?
Conversation
de0fb2a
to
88d69ab
Compare
@tolikzinovyev @curiecrypt @djetchev Should we remove the benchmarks checking the variance of the number of repetitions (the Some local tests showed me that we would need to reduce |
Removing the benchmark sounds reasonable! |
I find @tolikzinovyev idea the best. What do you think @curiecrypt @djetchev ? |
I will not have time to review this PR before Monday, unfortunately, since it is a pretty large. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice usage of advanced criterion features. Left high-level comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it seems pretty good and mature. I left a few comments and could go for another round after the conversations are resolved.
14f4fb0
to
3fdfe36
Compare
9f13518
to
e27b0d4
Compare
b540e25
to
a54996e
Compare
63a4cef
to
07fc567
Compare
5d2b638
to
5ab0b6f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just reviewed the centralized_telescope
benches.
Just very minor suggestions, other than that, it looks very good.
5ab0b6f
to
cba63c9
Compare
Co-authored-by: curiecrypt <[email protected]>
Co-authored-by: curiecrypt <[email protected]>
Co-authored-by: curiecrypt <[email protected]>
Co-authored-by: curiecrypt <[email protected]>
Co-authored-by: curiecrypt <[email protected]>
Co-authored-by: curiecrypt <[email protected]>
350cc03
to
f422cdb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code structure, benchmarks duration and variable names have definitely improved, thank you!
} | ||
} | ||
|
||
/// Prove routing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a typo. But also there is no need to document internal functions if the documentation doesn't say more than the function name.
@@ -52,6 +51,35 @@ pub(super) fn verify(setup: &Setup, proof: &Proof) -> bool { | |||
proof_hash(setup, &round) | |||
} | |||
|
|||
/// Internal module for tests and benchmarks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Internal module for tests and benchmarks | |
/// Internal module for tests and benchmarks. Do not use. |
@@ -8,7 +8,8 @@ use crate::utils::types::Element; | |||
/// The main centralized Telescope struct with prove and verify functions. | |||
#[derive(Debug, Clone, Copy)] | |||
pub struct Wrapper { | |||
setup: Setup, | |||
/// Centralized telescope internal parameters | |||
pub setup: Setup, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this shouldn't be public. Instead of calling CentralizedTelescope::create()
, we can run parameter derivation and use CentralizedTelescope::create_unsafe()
.
); | ||
} | ||
|
||
criterion_main!(criterion_group::centralized_verifying_time,); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
criterion_main!(criterion_group::centralized_verifying_time,); | |
criterion_main!(criterion_group::centralized_verifying_time); |
@@ -0,0 +1,42 @@ | |||
//! Benchmarking the proof size of the Centralized Telescope scheme |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this originally wasn't part of the PR. Could we postpone it to a later PR?
BenchmarkId::new( | ||
bench_name, | ||
format!( | ||
"params={{λsec:{}, λrel:{}, Sp:{} ({}%), n_p:{}, n_f:{}}}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example of current output:
params={λsec:80, λrel:80, Sp:1000 (80%), n_p:80, n_f:60}
.
As before, I think this is confusing because S_p is the size of prover's input and it's actually 800. Suggest the following output instead.
params={λsec:80, λrel:80, |Sp|:800 (80%), n_p:80, n_f:60}
BenchmarkId::new( | ||
bench_name, | ||
format!( | ||
"params={{λsec:{}, λrel:{}, Sp:{} ({}%), n_p:{}, n_f:{}}}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: also suggest a space after colons
} | ||
|
||
/// Prove routing | ||
fn prove_routine(setup: &Setup, prover_set: &[Element]) -> (u64, u64, Option<Proof>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use the number of retries anywhere, right? If not, let's not return it.
let mut total_steps = 0u64; | ||
for _ in 0..n { | ||
// Setup | ||
let (mut dataset, telescope) = setup(&mut rng, param); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still really think the setup should run before this loop. I think this loop (where n
is typically from 1 to 4 in our benchmarks) is intended to filter out external noises like unpredictable scheduling of processes by the OS. It is not intended to reduce the inherent variance of the measured value (here, number of dfs steps). By running the setup inside the loop, the measurement distribution becomes more concentrated around the average than it actually is.
I ran some experiments. This is for Centralized - Steps/Prove/params={λsec:64, λrel:64, Sp:1000 (90%), n_p:90, n_f:60}
.
Setup is moved to before the for loop:
You can see that moving the setup outside the loop makes the PDF graph wider which is what it should be.
Interestingly, the mean also changes by a lot, +34%. This is due to a small number of samples, currently 100. I ran the benchmark one more time:
Changing the number of samples to 1000 fixes the crazy variance. Perhaps, we should do this too.
use super::super::criterion_helpers::centralized::BenchParam; | ||
|
||
/// This case corresponds to the minimum security requirements with optimistic set_size | ||
const LOW_PARAM: BenchParam = BenchParam { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suppose I want to run a benchmark with particular n_p, n_f and |S_p| (size of prover's input). Currently, I would need to think hard to figure out how to correctly set the percentages and set_cardinality
here.
A better option could be to have
pub struct BenchParam {
pub lambda_sec: f64,
pub lambda_rel: f64,
pub set_cardinality: u64,
pub set_size: u64,
pub lower_bound: u64,
}
and have utility functions in this file that generate these structs based on percentages. There would be no low / mid / high cases in criterion_helpers.rs
benchmarks()
, instead they would be generated here.
What do you think?
Content
Relates to #54
Depends on #105