Skip to content

Commit f7d323f

Browse files
committed
Use continuous benchmarks action
1 parent 0c9ed21 commit f7d323f

4 files changed

Lines changed: 144 additions & 53 deletions

File tree

.github/workflows/benchmark.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Continuous Benchmarking
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
jobs:
16+
benchmark:
17+
name: Run Benchmarks
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout Code
21+
uses: actions/checkout@v4
22+
23+
- name: Run Full Benchmark Suite (on main)
24+
if: github.event_name == 'push'
25+
run: cargo bench -- --nocapture --output-format bencher > output.txt
26+
27+
- name: Run Lighter Benchmark Suite (on PR)
28+
if: github.event_name == 'pull_request'
29+
env:
30+
CORE_BENCHMARKS: '1'
31+
run: cargo bench --bench zip_benches -- --nocapture --output-format bencher > output.txt
32+
33+
- name: Post Benchmark Results on PR
34+
if: github.event_name == 'pull_request'
35+
uses: benchmark-action/github-action-benchmark@d48d326b4ca9ba73ca0cd0d59f108f9e02a381c7 # v1.20.4
36+
with:
37+
tool: 'cargo'
38+
output-file-path: 'output.txt'
39+
github-token: ${{ secrets.GITHUB_TOKEN }}
40+
comment-on-alert: true
41+
42+
- name: Save Benchmark History
43+
if: github.event_name == 'push'
44+
uses: benchmark-action/github-action-benchmark@d48d326b4ca9ba73ca0cd0d59f108f9e02a381c7 # v1.20.4
45+
with:
46+
tool: 'cargo'
47+
output-file-path: 'output.txt'
48+
github-token: ${{ secrets.GITHUB_TOKEN }}
49+
auto-push: true

Cargo.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,21 @@ itertools = "0.14.0"
3737
num-bigint = "0.4.6"
3838
num-integer = "0.1.46"
3939
num-traits = "0.2.19"
40+
p3-commit = { git = "https://github.com/Plonky3/Plonky3.git", rev = "5ebf8e4" }
41+
p3-field = { git = "https://github.com/Plonky3/Plonky3.git", rev = "5ebf8e4" }
42+
p3-matrix = { git = "https://github.com/Plonky3/Plonky3.git", rev = "5ebf8e4" }
43+
p3-maybe-rayon = { git = "https://github.com/Plonky3/Plonky3.git", rev = "5ebf8e4", features = [] }
44+
p3-merkle-tree = { git = "https://github.com/Plonky3/Plonky3.git", rev = "5ebf8e4" }
45+
p3-symmetric = { git = "https://github.com/Plonky3/Plonky3.git", rev = "5ebf8e4" }
46+
p3-util = { git = "https://github.com/Plonky3/Plonky3.git", rev = "5ebf8e4" }
4047
rand = "0.9.2"
4148
rayon = { version = "1.10.0", optional = true }
49+
serde = { version = "1.0", features = ["derive"] }
4250
sha3 = "0.10.8"
4351
thiserror = "2.0.12"
44-
zeroize = "1.8.1"
45-
p3-merkle-tree = { git = "https://github.com/Plonky3/Plonky3.git", rev = "5ebf8e4" }
46-
p3-symmetric = { git = "https://github.com/Plonky3/Plonky3.git", rev = "5ebf8e4" }
47-
p3-field = { git = "https://github.com/Plonky3/Plonky3.git", rev = "5ebf8e4" }
48-
p3-commit = { git = "https://github.com/Plonky3/Plonky3.git", rev = "5ebf8e4" }
49-
p3-matrix = { git = "https://github.com/Plonky3/Plonky3.git", rev = "5ebf8e4" }
50-
p3-util = { git = "https://github.com/Plonky3/Plonky3.git", rev = "5ebf8e4" }
51-
p3-maybe-rayon = { git = "https://github.com/Plonky3/Plonky3.git", rev = "5ebf8e4", features = [] }
5252
transpose = "0.2.3"
53-
serde = { version = "1.0", features = ["derive"] }
5453
uninit = "0.6.2"
54+
zeroize = "1.8.1"
5555

5656
[dev-dependencies]
5757
criterion = "0.7.0"

README.md

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
# **Zinc**
22

3-
4-
_Zinc_ is a proof-of-concept implementation of a novel SNARK system engineered by [Nethermind Research](https://www.nethermind.io/nethermind-research), based on [Zinc: Succinct Arguments with Small Arithmetization
3+
_Zinc_ is a proof-of-concept implementation of a novel SNARK system engineered
4+
by [Nethermind Research](https://www.nethermind.io/nethermind-research), based
5+
on [Zinc: Succinct Arguments with Small Arithmetization
56
Overheads from IOPs of Proximity to the Integers](https://eprint.iacr.org/2025/316) by
67
Albert Garreta, Hendrik Waldner, Katerina Hristova and Luca Dall'Ava.
78

8-
The primary goal of _Zinc_ is to address a significant performance bottleneck in modern zero-knowledge proof systems, specifically the high cost of arithmetization.
9+
The primary goal of _Zinc_ is to address a significant performance bottleneck in modern zero-knowledge proof systems,
10+
specifically the high cost of arithmetization.
911

1012
⚠️ **Disclaimer:** This is a proof-of-concept prototype.
11-
This implementation is provided for research and evaluation purposes. It has not undergone a formal security audit or comprehensive code review and is NOT ready for production use. Use at your own risk.
12-
13+
This implementation is provided for research and evaluation purposes. It has not undergone a formal security audit or
14+
comprehensive code review and is NOT ready for production use. Use at your own risk.
1315

1416
## **Repository Structure**
1517

16-
The Zinc codebase is organized into several distinct modules, each responsible for a core component of the cryptographic system.
18+
The Zinc codebase is organized into several distinct modules, each responsible for a core component of the cryptographic
19+
system.
1720

1821
| Path | Description |
1922
|:--------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
@@ -33,9 +36,9 @@ Follow these instructions to build, test and benchmark the Zinc library.
3336
### **Prerequisites**
3437

3538
Ensure you have the following installed:
36-
- **Rust**: Install Rust using [rustup](https://rustup.rs/).
37-
- **git**: Ensure you have Git installed to clone the repository.
3839

40+
- **Rust**: Install Rust using [rustup](https://rustup.rs/).
41+
- **git**: Ensure you have Git installed to clone the repository.
3942

4043
### **Building the Library**
4144

@@ -49,7 +52,8 @@ cargo build --release
4952

5053
#### **Building the Library with parallelization enabled**
5154

52-
For improved performance on multicore systems, you can enable parallelization by using the `parallel` feature flag, which uses Rayon for parallel processing.
55+
For improved performance on multicore systems, you can enable parallelization by using the `parallel` feature flag,
56+
which uses Rayon for parallel processing.
5357

5458
```bash
5559
cargo build --release --features "parallel"
@@ -63,25 +67,53 @@ cargo test --release
6367

6468
### **Running Benchmarks**
6569

66-
The repository includes a suite of benchmarks using Criterion.rs. To run the benchmarks, execute:
70+
The repository includes a suite of benchmarks using Criterion.rs. You can run the full suite or a lighter, core subset (
71+
used in CI for pull requests).
72+
73+
- Full local run (all benches):
6774

6875
```bash
6976
cargo bench
7077
```
7178

79+
- Core subset only (fast):
80+
81+
```bash
82+
CORE_BENCHMARKS=1 cargo bench --bench zip_benches
83+
```
84+
85+
Notes:
86+
87+
- The environment variable `CORE_BENCHMARKS=1` switches zip_benches.rs into a reduced set of cases for faster iteration.
88+
- We pass `--output-format bencher` to produce output compatible with our CI reporting.
89+
90+
#### CI Benchmarking
91+
92+
Our GitHub Actions workflow runs benchmarks automatically:
93+
94+
- On pushes to `main`: the full benchmark suite (`cargo bench -- --nocapture --output-format bencher`), and saves
95+
history via benchmark-action.
96+
- On pull requests: a lighter suite focused on the Zip PCS (
97+
`CORE_BENCHMARKS=1 cargo bench --bench zip_benches -- --nocapture --output-format bencher`), and posts results to the
98+
PR.
99+
100+
Continuous benchmark results can be viewed at [GitHub pages](https://NethermindEth.github.io/zinc/dev/bench)
101+
72102
## **Example**
73103

74104
For usage example you can refer to the example [r1cs.rs](examples/simple_r1cs.rs) file.
75105

76-
77106
## Usage
107+
78108
Import the library:
109+
79110
```toml
80111
[dependencies]
81112
zinc = { git = "https://github.com/NethermindEth/zinc.git" }
82113
```
83114
84115
## License
116+
85117
The crates in this repository are licensed under the following licence.
86118
87119
* MIT license ([LICENSE](./LICENSE))

benches/zip_benches.rs

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -224,45 +224,55 @@ fn verify<const P: usize>(group: &mut BenchmarkGroup<WallTime>, modulus: &str, s
224224

225225
fn zip_benchmarks(c: &mut Criterion) {
226226
let mut group = c.benchmark_group("Zip");
227+
let core_only = ark_std::env::var("CORE_BENCHMARKS").is_ok();
228+
let modulus = "106319353542452952636349991594949358997917625194731877894581586278529202198383";
227229

228-
encode_rows::<12>(&mut group, 1);
229-
encode_rows::<13>(&mut group, 1);
230-
encode_rows::<14>(&mut group, 1);
231-
encode_rows::<15>(&mut group, 1);
232-
encode_rows::<16>(&mut group, 1);
233-
234-
encode_single_row::<128>(&mut group, 1);
235-
encode_single_row::<256>(&mut group, 1);
236-
encode_single_row::<512>(&mut group, 1);
237-
encode_single_row::<1024>(&mut group, 1);
238-
encode_single_row::<2048>(&mut group, 1);
239-
encode_single_row::<4096>(&mut group, 1);
230+
if core_only {
231+
// Core, fast set
232+
encode_rows::<12>(&mut group, 1);
233+
encode_single_row::<128>(&mut group, 1);
234+
merkle_root::<12>(&mut group, 1);
235+
commit::<12>(&mut group, 1);
236+
verify::<12>(&mut group, modulus, 1);
237+
} else {
238+
// Full suite (your current behavior)
239+
encode_rows::<12>(&mut group, 1);
240+
encode_rows::<13>(&mut group, 1);
241+
encode_rows::<14>(&mut group, 1);
242+
encode_rows::<15>(&mut group, 1);
243+
encode_rows::<16>(&mut group, 1);
240244

241-
merkle_root::<12>(&mut group, 1);
242-
merkle_root::<13>(&mut group, 1);
243-
merkle_root::<14>(&mut group, 1);
244-
merkle_root::<15>(&mut group, 1);
245-
merkle_root::<16>(&mut group, 1);
245+
encode_single_row::<128>(&mut group, 1);
246+
encode_single_row::<256>(&mut group, 1);
247+
encode_single_row::<512>(&mut group, 1);
248+
encode_single_row::<1024>(&mut group, 1);
249+
encode_single_row::<2048>(&mut group, 1);
250+
encode_single_row::<4096>(&mut group, 1);
246251

247-
commit::<12>(&mut group, 1);
248-
commit::<13>(&mut group, 1);
249-
commit::<14>(&mut group, 1);
250-
commit::<15>(&mut group, 1);
251-
commit::<16>(&mut group, 1);
252+
merkle_root::<12>(&mut group, 1);
253+
merkle_root::<13>(&mut group, 1);
254+
merkle_root::<14>(&mut group, 1);
255+
merkle_root::<15>(&mut group, 1);
256+
merkle_root::<16>(&mut group, 1);
252257

253-
let modulus = "106319353542452952636349991594949358997917625194731877894581586278529202198383";
258+
commit::<12>(&mut group, 1);
259+
commit::<13>(&mut group, 1);
260+
commit::<14>(&mut group, 1);
261+
commit::<15>(&mut group, 1);
262+
commit::<16>(&mut group, 1);
254263

255-
open::<12>(&mut group, modulus, 1);
256-
open::<13>(&mut group, modulus, 1);
257-
open::<14>(&mut group, modulus, 1);
258-
open::<15>(&mut group, modulus, 1);
259-
open::<16>(&mut group, modulus, 1);
264+
open::<12>(&mut group, modulus, 1);
265+
open::<13>(&mut group, modulus, 1);
266+
open::<14>(&mut group, modulus, 1);
267+
open::<15>(&mut group, modulus, 1);
268+
open::<16>(&mut group, modulus, 1);
260269

261-
verify::<12>(&mut group, modulus, 1);
262-
verify::<13>(&mut group, modulus, 1);
263-
verify::<14>(&mut group, modulus, 1);
264-
verify::<15>(&mut group, modulus, 1);
265-
verify::<16>(&mut group, modulus, 1);
270+
verify::<12>(&mut group, modulus, 1);
271+
verify::<13>(&mut group, modulus, 1);
272+
verify::<14>(&mut group, modulus, 1);
273+
verify::<15>(&mut group, modulus, 1);
274+
verify::<16>(&mut group, modulus, 1);
275+
}
266276

267277
group.finish();
268278
}

0 commit comments

Comments
 (0)