|
| 1 | +# Lambda VM vs SP1 v6 Benchmark |
| 2 | + |
| 3 | +Compares proving time for an identical u64 wrapping Fibonacci computation. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +1. **Lambda VM CLI** (built from this repo): |
| 8 | + ```bash |
| 9 | + cargo build --release -p cli |
| 10 | + ``` |
| 11 | + |
| 12 | +2. **SP1 toolchain** (Succinct's prover): |
| 13 | + ```bash |
| 14 | + curl -L https://sp1up.succinct.xyz | bash |
| 15 | + sp1up |
| 16 | + ``` |
| 17 | + |
| 18 | +3. **Rust nightly** (for cross-compiling Lambda VM guest): |
| 19 | + ```bash |
| 20 | + rustup toolchain install nightly |
| 21 | + ``` |
| 22 | + |
| 23 | +## Usage |
| 24 | + |
| 25 | +```bash |
| 26 | +# Default series: 1k, 10k, 100k, 300k iterations |
| 27 | +./bench_vs/run.sh |
| 28 | + |
| 29 | +# Custom series |
| 30 | +./bench_vs/run.sh -n 1000 50000 |
| 31 | + |
| 32 | +# Approximate workload steps (converted with 5 steps/iteration) |
| 33 | +./bench_vs/run.sh --steps 1000000 2000000 4000000 8000000 |
| 34 | + |
| 35 | +# Project to a target cycle count |
| 36 | +./bench_vs/run.sh --target-cycles 500000000 |
| 37 | + |
| 38 | +# Run only one prover |
| 39 | +./bench_vs/run.sh --lambda-only |
| 40 | +./bench_vs/run.sh --sp1-only |
| 41 | +``` |
| 42 | + |
| 43 | +## What is measured |
| 44 | + |
| 45 | +Both provers execute the same program: iterative Fibonacci with `u64::wrapping_add`. |
| 46 | + |
| 47 | +The timing window on both sides is **end-to-end single-shot proving, with no |
| 48 | +verification and no recursion/compression**. Concretely: |
| 49 | + |
| 50 | +| Phase | Lambda VM timer | SP1 v6 timer | |
| 51 | +|--------------------------------------------|:---------------:|:------------:| |
| 52 | +| Read ELF + input from disk | ❌ | ❌ | |
| 53 | +| Pre-pass execution to count cycles | ❌ | ❌ | |
| 54 | +| `setup` / verifying-key derivation | N/A (none) | ✅ | |
| 55 | +| ELF parse + guest execution (inside prove) | ✅ | ✅ | |
| 56 | +| Trace build | ✅ | ✅ | |
| 57 | +| AIR construction | ✅ | ✅ | |
| 58 | +| STARK prove (`core` mode) | ✅ | ✅ | |
| 59 | +| Proof serialization / write | ❌ | ❌ | |
| 60 | +| Verify | ❌ | ❌ | |
| 61 | + |
| 62 | +Both sides run one extra execution pass **outside** the timer to report dynamic |
| 63 | +instruction counts (SP1's `execute(...)` / Lambda's executor pre-pass). This |
| 64 | +costs wall-clock time in the CI job but does not inflate the measured proving |
| 65 | +time, and the cost is symmetric between the two provers. |
| 66 | + |
| 67 | +Lambda VM uses the default proof options from `prover::prove_with_inputs` |
| 68 | +(`GoldilocksCubicProofOptions::with_blowup(2)`, 50 FRI queries). SP1 v6 uses |
| 69 | +the `core` proof mode exposed by `sp1-sdk::ProverClient::from_env()`. |
| 70 | + |
| 71 | +## Projection axis |
| 72 | + |
| 73 | +The linear projection uses **measured cycles** per prover — Lambda's executor |
| 74 | +log count and SP1's `report.total_instruction_count()`. For Fibonacci the two |
| 75 | +values agree to within ~1% (both compile to the same inner loop shape on |
| 76 | +RISC-V). When cycle data is missing, the script falls back to the approximate |
| 77 | +`target_workload_steps ~= 5 * n` label that was passed on the command line. |
| 78 | + |
| 79 | +## Output |
| 80 | + |
| 81 | +``` |
| 82 | +=== Summary === |
| 83 | +Program: Fibonacci (u64 wrapping) |
| 84 | +
|
| 85 | + Target steps Iterations Lambda (s) Lambda cycles SP1 (s) SP1 cycles Ratio |
| 86 | + ------------ ---------- ---------- ------------- ------- ---------- ----- |
| 87 | + 1000000 200000 ...s 1004794 ...s 1004794 ... |
| 88 | + 2000000 400000 ...s 2004794 ...s 2004794 ... |
| 89 | +
|
| 90 | +Timing window covers single-shot end-to-end proving; SP1 includes setup; both exclude verification. |
| 91 | +Green ratio = Lambda VM faster, Red = SP1 faster |
| 92 | +``` |
| 93 | + |
| 94 | +With `--report-dir DIR` the script writes: |
| 95 | +- `results.tsv` — raw per-run data (`target_steps`, `iterations`, `lambda_time_s`, `lambda_axis_value`, `lambda_cycles`, `sp1_time_s`, `sp1_axis_value`, `sp1_cycles`, `ratio`). |
| 96 | +- `metrics.txt` — key=value pairs including `timing_window=setup_plus_end_to_end_prove_no_verify`. |
| 97 | +- `summary.md` — the same table plus linear projection to `TARGET_CYCLES` cycles. |
| 98 | +- `raw/` — stdout/stderr of every individual run. |
0 commit comments