Skip to content

Commit e8393b5

Browse files
committed
github action benchmark
1 parent a91ad8b commit e8393b5

File tree

3 files changed

+102
-12
lines changed

3 files changed

+102
-12
lines changed

.github/workflows/benchmark.yml

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,63 @@ jobs:
3434
- name: Generate gates report
3535
run: ./scripts/build-gates-report.sh
3636
env:
37-
BACKEND: /home/runner/.bb/bb
37+
BACKEND: /home/runner/.bb/bb
3838

39-
- name: Compare gates reports
40-
id: gates_diff
41-
uses: noir-lang/noir-gates-diff@dbe920a8dcc3370af4be4f702ca9cef29317bec1
39+
- name: Store ACIR opcode benchmark result
40+
uses: benchmark-action/github-action-benchmark@v1
4241
with:
43-
report: gates_report.json
44-
summaryQuantile: 0.9 # only display the 10% most significant circuit size diffs in the summary (defaults to 20%)
42+
name: "ACIR Opcodes"
43+
tool: "customSmallerIsBetter"
44+
output-file-path: "benchmark-opcodes.json"
45+
gh-pages-branch: "gh-pages"
46+
benchmark-data-dir-path: "dev/bench"
47+
github-token: ${{ secrets.GITHUB_TOKEN }}
48+
auto-push: ${{ github.ref == 'refs/heads/main' }}
49+
comment-always: ${{ contains( github.event.pull_request.labels.*.name, 'bench-show') }}
50+
comment-on-alert: true
51+
alert-threshold: "101%"
52+
fail-on-alert: false
53+
max-items-in-chart: 50
4554

46-
- name: Add gates diff to sticky comment
47-
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
48-
uses: marocchino/sticky-pull-request-comment@v2
55+
- name: Store gates benchmark result
56+
uses: benchmark-action/github-action-benchmark@v1
4957
with:
50-
# delete the comment in case changes no longer impact circuit sizes
51-
delete: ${{ !steps.gates_diff.outputs.markdown }}
52-
message: ${{ steps.gates_diff.outputs.markdown }}
58+
name: "Circuit Size"
59+
tool: "customSmallerIsBetter"
60+
output-file-path: "benchmark-circuit.json"
61+
gh-pages-branch: "gh-pages"
62+
benchmark-data-dir-path: "dev/bench"
63+
github-token: ${{ secrets.GITHUB_TOKEN }}
64+
auto-push: ${{ github.ref == 'refs/heads/main' }}
65+
comment-always: ${{ contains( github.event.pull_request.labels.*.name, 'bench-show') }}
66+
comment-on-alert: true
67+
alert-threshold: "101%"
68+
fail-on-alert: false
69+
max-items-in-chart: 50
70+
skip-fetch-gh-pages: true
71+
72+
- name: Delete export files
73+
run: rm -rf export
74+
75+
- name: Build Brillig benchmark programs
76+
run: nargo export --force-brillig
77+
78+
- name: Generate brillig report
79+
run: ./ethereum/scripts/build-brillig-report.sh
80+
81+
- name: Store brillig benchmark result
82+
uses: benchmark-action/github-action-benchmark@v1
83+
with:
84+
name: "Brillig Bytecode Size"
85+
tool: "customSmallerIsBetter"
86+
output-file-path: "benchmark-brillig.json"
87+
gh-pages-branch: "gh-pages"
88+
benchmark-data-dir-path: "dev/bench"
89+
github-token: ${{ secrets.GITHUB_TOKEN }}
90+
auto-push: ${{ github.ref == 'refs/heads/main' }}
91+
comment-always: ${{ contains( github.event.pull_request.labels.*.name, 'bench-show') }}
92+
comment-on-alert: true
93+
alert-threshold: "101%"
94+
fail-on-alert: false
95+
max-items-in-chart: 50
96+
skip-fetch-gh-pages: true

scripts/build-brillig-report.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
INSPECTOR=${INSPECTOR:-noir-inspector}
5+
cd $(dirname "$0")/../
6+
7+
artifacts_path="./export"
8+
artifacts=$(ls $artifacts_path)
9+
10+
# Start the JSON array
11+
REPORTS=$(jq --null-input '[]')
12+
13+
for artifact in $artifacts; do
14+
# Get and format the opcode info
15+
OP_CODE_INFO=$($INSPECTOR info --json "$artifacts_path/$artifact")
16+
17+
# Simplified jq expression to output only package_name and opcodes from unconstrained_functions
18+
REPORTS=$(echo $OP_CODE_INFO | jq -c '.programs[0] | del(.functions)' | jq -c --argjson old_reports $REPORTS '$old_reports + [.]')
19+
done
20+
21+
echo $REPORTS | jq '{ programs: . }' > brillig_report.json
22+
23+
# Convert brillig report to benchmark format
24+
output_file_brillig="benchmark-brillig.json"
25+
jq -r '[.programs[] | .unconstrained_functions[] | {
26+
"name": (if (.package_name // "") == "" then .name else "\(.package_name | sub("^null/"; ""))/\(.name)" end),
27+
"unit": "opcodes",
28+
"value": (.opcodes // 0)
29+
}]' brillig_report.json > $output_file_brillig

scripts/build-gates-report.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,21 @@ done
3232

3333
echo "]}" >> gates_report.json
3434

35+
# Convert the gates report into separate benchmark files
36+
output_file_opcodes="benchmark-opcodes.json"
37+
output_file_circuit="benchmark-circuit.json"
38+
39+
# Convert gates report - opcodes
40+
jq -r '[.programs[] | {
41+
"name": "\(.package_name)/main",
42+
"unit": "acir_opcodes",
43+
"value": (.functions[0].acir_opcodes // 0)
44+
}]' gates_report.json > $output_file_opcodes
45+
46+
# Convert gates report - circuit size
47+
jq -r '[.programs[] | {
48+
"name": "\(.package_name)/main",
49+
"unit": "circuit_size",
50+
"value": (.functions[0].circuit_size // 0)
51+
}]' gates_report.json > $output_file_circuit
3552

0 commit comments

Comments
 (0)