Skip to content
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

Refactor benchmarks #161

Merged
merged 3 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions latticefold/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ thiserror = { workspace = true }
num-bigint = { workspace = true }
rayon = { version = "1.10.0", optional = true }


[build-dependencies]
serde = { version = "1.0.216", features = ["derive"] }
toml = "0.8.19"
quote = "1.0.37"
proc-macro2 = "1.0.92"

[features]
default = [ "std" ]
std = [ "ark-std/std", "cyclotomic-rings/std", "rand/std" ]
Expand All @@ -40,6 +47,12 @@ dhat-heap = []
[profile.release]
debug = 1

[profile.bench]
lto = false
codegen-units = 16
opt-level = 3
rpath = true

[lints.clippy]
single_match = "warn"
single_match_else = "warn"
Expand All @@ -60,6 +73,7 @@ implicit_clone = "warn"
criterion = "0.5.1"
dhat = "0.3.2"
humansize = "2.1.3"
lazy_static = "1.5.0"

[[bench]]
name = "ajtai"
Expand All @@ -69,10 +83,12 @@ harness = false
name = "linearization"
harness = false


[[bench]]
name = "decomposition"
harness = false


[[bench]]
name = "folding"
harness = false
Expand Down
96 changes: 96 additions & 0 deletions latticefold/benches/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Benchmarking with Environment Variables

This benchmark suite allows users to selectively enable or disable certain benchmarks using environment variables. By leveraging environment variables, users can tailor the benchmark runs to specific configurations.

---

## Environment Variables

The following environment variables can be set to **enable or filter benchmarks**:

### Boolean Flags (Enable/Disable Filtering)
- `GOLDILOCKS`
- `STARK`
- `BABYBEAR`
- `FROG`

- `PROVER`
- `VERIFIER`
- `AJTAI`

- `LINEARIZATION`
- `DECOMPOSITION`
- `FOLDING`
- `E2E`

> **Default Behavior**:
If none of the flags for a group are set, all flags are enabled by default.

### Optional Variables (Numeric Values)
The following variables control specific parameters for benchmarks. If not set, they will be ignored:
- `DURATION` (default: `50.0` seconds as floating point number) – Duration for benchmarks
- `WARMUP` (default: `1.0` seconds as floating point number) – Warmup time

---

## How It Works
- If none of `LINEARIZATION`, `DECOMPOSITION`, `FOLDING`, and `E2E` is set, all benchmarks would be run.
- If some of them is set, only set benchmarks would be run.
- Similarly, if none of `PROVER`, `VERIFIER` and `AJTAI` is set, all benchmarks would be run, otherwise,
only set benchmarks would be run.
- `GOLDILOCKS`, `STARK`, `BABYBEAR` and `FROG` are used similarly.

---

## Examples

### **Bash**

1. **Run only `LINEARIZATION` benchmarks:**
```bash
LINEARIZATION=1 cargo bench
```

2. **Run only `PROVER` `DECOMPOSITION` benchmarks:**
```bash
PROVER=1 DECOMPOSITION=1 cargo bench
```

3. **Run benchmarks matching specific parameters for GOLDILOCKS ring:**
```bash
KAPPA=10 GOLDILOCKS=1 L=8 GOLDILOCKS=1 cargo bench
```

---

### **PowerShell**
1. **Run only `LINEARIZATION` benchmarks:**
```powershell
$env:LINEARIZATION=1; cargo bench
```

2. **Run only `PROVER` `DECOMPOSITION` benchmarks:**
```powershell
$env:PROVER=1; $env:DECOMPOSITION=1; cargo bench
```

3. **Run benchmarks matching specific parameters for GOLDILOCKS ring:**
```powershell
$env:KAPPA=10; $env:GOLDILOCKS=1; $env:L=8; $env:GOLDILOCKS=1; cargo bench
```

---

## Numeric Parameters

Numeric parameters can be used to filter benchmarks, if they are set they only benchmarks with matching parameter would be run

- X_LEN
- KAPPA
- W
- WIT_LEN
- B
- L
- B_SMALL
- K

Loading
Loading