Skip to content

Commit

Permalink
chore: Enhance benchmark setup and update rust-toolchain
Browse files Browse the repository at this point in the history
- Enhanced identification and tracking for benchmarks by moving 'date' and 'sha' fields to `ProveParams` struct.
- Tuned the `fibo_prove` function to utilize the new fields for better benchmark IDs (see lurk-lab#782)
- Updated `rust-toolchain` version from `1.72.1` to `1.73.0` enhancing overall runtime environment.
- Counted throughput in frames / s.

This performs the straightforward parts of lurk-lab#782, re-opened after lurk-lab#784 was reverted (in lurk-lab#808)
  • Loading branch information
huitseeker committed Oct 31, 2023
1 parent 233bf4b commit 34ea708
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 10 deletions.
21 changes: 17 additions & 4 deletions benches/fibonacci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ fn fib_limit(n: usize, rc: usize) -> usize {
struct ProveParams {
fib_n: usize,
reduction_count: usize,
date: &'static str,
sha: &'static str,
}

impl ProveParams {
fn name(&self) -> String {
let date = env!("VERGEN_GIT_COMMIT_DATE");
let sha = env!("VERGEN_GIT_SHA");
format!("{date}:{sha}:Fibonacci-rc={}", self.reduction_count)
format!("Fibonacci-num={}", self.fib_n)
}
}

Expand All @@ -73,6 +73,8 @@ fn fibo_prove<M: measurement::Measurement>(
let ProveParams {
fib_n,
reduction_count,
date,
sha,
} = prove_params;

let limit = fib_limit(fib_n, reduction_count);
Expand All @@ -88,8 +90,17 @@ fn fibo_prove<M: measurement::Measurement>(
);
let pp = public_params::<_, _, MultiFrame<'_, _, _>>(&instance).unwrap();

// Track the number of `Lurk frames / sec`
let rc = reduction_count as u64;
c.throughput(criterion::Throughput::Elements(
rc * u64::div_ceil((11 + 16 * fib_n) as u64, rc),
));

c.bench_with_input(
BenchmarkId::new(prove_params.name(), fib_n),
BenchmarkId::new(
prove_params.name(),
format!("rc-{}/{sha}-{date}", prove_params.reduction_count),
),
&prove_params,
|b, prove_params| {
let store = Store::default();
Expand Down Expand Up @@ -133,6 +144,8 @@ fn fibonacci_prove(c: &mut Criterion) {
let prove_params = ProveParams {
fib_n: *fib_n,
reduction_count: *reduction_count,
date: env!("VERGEN_GIT_COMMIT_DATE"),
sha: env!("VERGEN_GIT_SHA"),
};
fibo_prove(prove_params, &mut group, &state);
}
Expand Down
23 changes: 18 additions & 5 deletions benches/fibonacci_lem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ fn fib_limit(n: usize, rc: usize) -> usize {
struct ProveParams {
fib_n: usize,
reduction_count: usize,
date: &'static str,
sha: &'static str,
}

impl ProveParams {
fn name(&self) -> String {
let date = env!("VERGEN_GIT_COMMIT_DATE");
let sha = env!("VERGEN_GIT_SHA");
format!("{date}:{sha}:Fibonacci-LEM-rc={}", self.reduction_count)
format!("Fibonacci-num={}", self.fib_n)
}
}

Expand All @@ -68,6 +68,8 @@ fn fibo_prove<M: measurement::Measurement>(
let ProveParams {
fib_n,
reduction_count,
date,
sha,
} = prove_params;

let limit = fib_limit(fib_n, reduction_count);
Expand All @@ -83,8 +85,17 @@ fn fibo_prove<M: measurement::Measurement>(
);
let pp = public_params::<_, _, MultiFrame<'_, _, _>>(&instance).unwrap();

// Track the number of `Lurk frames / sec`
let rc = reduction_count as u64;
c.throughput(criterion::Throughput::Elements(
rc * u64::div_ceil((11 + 16 * fib_n) as u64, rc),
));

c.bench_with_input(
BenchmarkId::new(prove_params.name(), fib_n),
BenchmarkId::new(
prove_params.name(),
format!("rc-{}/{sha}-{date}", prove_params.reduction_count),
),
&prove_params,
|b, prove_params| {
let store = Store::default();
Expand Down Expand Up @@ -118,7 +129,7 @@ fn fibonacci_prove(c: &mut Criterion) {
tracing::debug!("{:?}", lurk::config::LURK_CONFIG);
let reduction_counts = [100, 600, 700, 800, 900];
let batch_sizes = [100, 200];
let mut group: BenchmarkGroup<'_, _> = c.benchmark_group("Prove");
let mut group: BenchmarkGroup<'_, _> = c.benchmark_group("LEM Prove");
group.sampling_mode(SamplingMode::Flat); // This can take a *while*
group.sample_size(10);
let state = State::init_lurk_state().rccell();
Expand All @@ -128,6 +139,8 @@ fn fibonacci_prove(c: &mut Criterion) {
let prove_params = ProveParams {
fib_n: *fib_n,
reduction_count: *reduction_count,
date: env!("VERGEN_GIT_COMMIT_DATE"),
sha: env!("VERGEN_GIT_SHA"),
};
fibo_prove(prove_params, &mut group, &state);
}
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.72.1
1.73.0

0 comments on commit 34ea708

Please sign in to comment.