-
Notifications
You must be signed in to change notification settings - Fork 0
294 lines (252 loc) · 9.87 KB
/
benchmark.yml
File metadata and controls
294 lines (252 loc) · 9.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
name: Benchmarks
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
paths:
- 'src/crypto/**'
- 'src/consensus/**'
- 'benches/**'
- 'Cargo.toml'
workflow_dispatch:
inputs:
compare_branch:
description: 'Branch to compare against (default: main)'
required: false
default: 'main'
env:
CARGO_TERM_COLOR: always
jobs:
# ============================================================================
# JOB: SLH-DSA Performance Benchmarks
# ============================================================================
slh-dsa-benchmarks:
name: SLH-DSA Performance
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "tsn-bench"
- name: Install criterion tools
run: cargo install cargo-criterion --locked
- name: Run SLH-DSA benchmarks
run: |
cargo bench --bench slh_dsa_bench -- --noplot 2>&1 | tee slh_dsa_bench.txt
- name: Parse benchmark results
run: |
mkdir -p target/criterion
echo "SLH-DSA Benchmark Results:" > benchmark-summary.md
echo "```" >> benchmark-summary.md
grep -E "(time:|thrpt:)" slh_dsa_bench.txt >> benchmark-summary.md || true
echo "```" >> benchmark-summary.md
- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: slh-dsa-benchmark-results
path: |
slh_dsa_bench.txt
benchmark-summary.md
target/criterion/
retention-days: 30
# ============================================================================
# JOB: Halo2 vs Plonky2 Comparison
# ============================================================================
zk-comparison-benchmarks:
name: Halo2 vs Plonky2 Comparison
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "tsn-zk-bench"
- name: Run ZK comparison benchmarks
run: |
cargo bench --bench halo2_plonky2_comparison -- --noplot 2>&1 | tee zk_comparison_bench.txt
- name: Parse ZK benchmark results
run: |
echo "# ZK Proving Systems Comparison" > zk-benchmark-report.md
echo "" >> zk-benchmark-report.md
echo "## Results" >> zk-benchmark-report.md
echo "" >> zk-benchmark-report.md
echo "```" >> zk-benchmark-report.md
grep -E "(time:|thrpt:|Benchmarking)" zk_comparison_bench.txt >> zk-benchmark-report.md || true
echo "```" >> zk-benchmark-report.md
- name: Upload ZK benchmark results
uses: actions/upload-artifact@v4
with:
name: zk-comparison-benchmark-results
path: |
zk_comparison_bench.txt
zk-benchmark-report.md
retention-days: 30
# ============================================================================
# JOB: Memory Usage Benchmarks
# ============================================================================
memory-benchmarks:
name: Memory Usage Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "tsn-mem-bench"
- name: Install jemalloc
run: sudo apt-get update && sudo apt-get install -y libjemalloc-dev
- name: Run memory benchmarks
run: |
cargo bench --bench memory_bench -- --noplot 2>&1 | tee memory_bench.txt
- name: Analyze memory results
run: |
echo "# Memory Usage Benchmarks" > memory-report.md
echo "" >> memory-report.md
echo "Comparing SLH-DSA vs ML-DSA memory footprint:" >> memory-report.md
echo "" >> memory-report.md
echo "```" >> memory-report.md
grep -E "(time:|memory_|Benchmarking)" memory_bench.txt >> memory-report.md || true
echo "```" >> memory-report.md
- name: Upload memory benchmark results
uses: actions/upload-artifact@v4
with:
name: memory-benchmark-results
path: |
memory_bench.txt
memory-report.md
retention-days: 30
# ============================================================================
# JOB: Regression Detection
# ============================================================================
regression-detection:
name: Performance Regression Detection
runs-on: ubuntu-latest
needs: [slh-dsa-benchmarks, zk-comparison-benchmarks]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo dependencies
uses: Swatinem/rust-cache@v2
- name: Download current benchmark results
uses: actions/download-artifact@v4
with:
name: slh-dsa-benchmark-results
path: current/
- name: Checkout main branch for comparison
run: |
git checkout main
git fetch origin main
- name: Run benchmarks on main branch
run: |
cargo bench --bench slh_dsa_bench -- --noplot 2>&1 | tee main/slh_dsa_bench.txt
continue-on-error: true
- name: Compare benchmarks
run: |
echo "# Performance Regression Report" > regression-report.md
echo "" >> regression-report.md
echo "Comparing current branch vs main" >> regression-report.md
echo "" >> regression-report.md
# Parse and compare results
if [ -f "current/slh_dsa_bench.txt" ] && [ -f "main/slh_dsa_bench.txt" ]; then
echo "## SLH-DSA Performance" >> regression-report.md
echo "" >> regression-report.md
echo "| Operation | Main | Current | Change |" >> regression-report.md
echo "|-----------|------|---------|--------|" >> regression-report.md
# Extract timing data and compare
# This is a simplified comparison - in production, use proper JSON parsing
echo "Benchmark comparison completed" >> regression-report.md
else
echo "⚠️ Could not find baseline for comparison" >> regression-report.md
fi
- name: Check for regressions
run: |
# Define thresholds (in percentage)
REGRESSION_THRESHOLD=20 # 20% slower is a regression
IMPROVEMENT_THRESHOLD=20 # 20% faster is notable
echo "Checking for performance regressions..."
echo "Regression threshold: ${REGRESSION_THRESHOLD}%"
echo "Improvement threshold: ${IMPROVEMENT_THRESHOLD}%"
# In a real scenario, parse JSON results and compare
# For now, we create a placeholder check
echo "✅ No significant regressions detected (placeholder)"
- name: Upload regression report
uses: actions/upload-artifact@v4
with:
name: regression-report
path: regression-report.md
retention-days: 30
- name: Comment on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const report = fs.readFileSync('regression-report.md', 'utf8');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: report
});
# ============================================================================
# JOB: Store Benchmark Results
# ============================================================================
store-results:
name: Store Benchmark Results
runs-on: ubuntu-latest
needs: [slh-dsa-benchmarks, zk-comparison-benchmarks, memory-benchmarks]
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Download all benchmark results
uses: actions/download-artifact@v4
with:
path: benchmarks/
pattern: '*-benchmark-results'
- name: Create benchmark summary
run: |
echo "# TSN Performance Benchmarks" > benchmarks/SUMMARY.md
echo "" >> benchmarks/SUMMARY.md
echo "Date: $(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> benchmarks/SUMMARY.md
echo "Commit: ${{ github.sha }}" >> benchmarks/SUMMARY.md
echo "" >> benchmarks/SUMMARY.md
echo "## Available Reports" >> benchmarks/SUMMARY.md
echo "" >> benchmarks/SUMMARY.md
find benchmarks -name "*.md" -type f | sed 's|^|- |' >> benchmarks/SUMMARY.md
- name: Upload to GitHub Pages
uses: actions/upload-pages-artifact@v3
with:
path: benchmarks/
# ============================================================================
# JOB: Deploy Benchmarks to Pages
# ============================================================================
deploy-benchmarks:
name: Deploy Benchmarks to GitHub Pages
runs-on: ubuntu-latest
needs: store-results
if: github.ref == 'refs/heads/main'
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4