Skip to content

Commit

Permalink
refactor: witness caching skips the 1st witness. (#1226)
Browse files Browse the repository at this point in the history
* refactor: witness caching skips the 1st witness.

- Optimized the `prove_recursively` function in `RecursiveSNARKTrait` for performance enhancement
- Implemented on-demand computation for first circuit's witness in `prove_step`

* refactor: also skip the 1st witness for Supernova
  • Loading branch information
huitseeker authored Mar 20, 2024
1 parent 090931a commit 17454d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/proof/nova.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,12 @@ impl<F: CurveCycleEquipped, C: Coprocessor<F>> RecursiveSNARKTrait<F, C1LEM<F, C
let (step_sender, step_receiver) = mpsc::sync_channel(MAX_BUFFERED_FRAMES);
std::thread::scope(|s| {
s.spawn(move || {
for mut step in steps {
step.cache_witness(store).expect("witness caching failed");
for (i, mut step) in steps.enumerate() {
// Skip the very first circuit's witness, so `prove_step` can begin immediately.
// That circuit's witness will not be cached and will just be computed on-demand.
if i > 0 {
step.cache_witness(store).expect("witness caching failed");
}
if step_sender.send(step).is_err() {
// The main thread has dropped the receiver, so we can stop
return;
Expand Down
8 changes: 6 additions & 2 deletions src/proof/supernova.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,12 @@ impl<F: CurveCycleEquipped, C: Coprocessor<F>> RecursiveSNARKTrait<F, C1LEM<F, C

std::thread::scope(|s| {
s.spawn(move || {
for mut step in steps {
step.cache_witness(store).expect("witness caching failed");
for (i, mut step) in steps.enumerate() {
// Skip the very first circuit's witness, so `prove_step` can begin immediately.
// That circuit's witness will not be cached and will just be computed on-demand.
if i > 0 {
step.cache_witness(store).expect("witness caching failed");
}
if step_sender.send(step).is_err() {
// The main thread has dropped the receiver, so we can stop
return;
Expand Down

1 comment on commit 17454d2

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

Benchmarks

Table of Contents

Overview

This benchmark report shows the Fibonacci GPU benchmark.
NVIDIA L4
Intel(R) Xeon(R) CPU @ 2.20GHz
32 vCPUs
125 GB RAM
Workflow run: https://github.com/lurk-lab/lurk-rs/actions/runs/8362086839

Benchmark Results

LEM Fibonacci Prove - rc = 100

ref=090931a24dbf871464ccb41eace5dc3b1f70f993 ref=17454d274921219308f1eafa9159d38fc5ac0ce7
num-100 1.51 s (✅ 1.00x) 1.47 s (✅ 1.03x faster)
num-200 2.86 s (✅ 1.00x) 2.80 s (✅ 1.02x faster)

LEM Fibonacci Prove - rc = 600

ref=090931a24dbf871464ccb41eace5dc3b1f70f993 ref=17454d274921219308f1eafa9159d38fc5ac0ce7
num-100 1.93 s (✅ 1.00x) 1.86 s (✅ 1.04x faster)
num-200 3.15 s (✅ 1.00x) 3.07 s (✅ 1.03x faster)

Made with criterion-table

Please sign in to comment.