-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add Brillig loop bytecode size regression and update noir-gate…
…s-diff report (#5747) # Description ## Problem\* Resolves <!-- Link to GitHub Issue --> ## Summary\* Successful example report: <img width="964" alt="Screenshot 2024-08-19 at 9 31 35 AM" src="https://github.com/user-attachments/assets/ccbddccd-a38a-4853-bcc2-1ac6bcb1fe36"> I originally just had this PR as a draft to test and close, but we can just keep the PR now to add a size regression test for issue #4535: ``` struct EnumEmulation { a: Option<Field>, b: Option<Field>, c: Option<Field>, } unconstrained fn main() -> pub Field { let mut emulated_enum = EnumEmulation { a: Option::some(1), b: Option::none(), c: Option::none() }; assert_eq(emulated_enum.a.unwrap(), 1); emulated_enum.a = Option::some(2); emulated_enum.a.unwrap() } ``` This PR also provides a quicker way of updating the noir-gates-diff commit as the original PR (#5745) will first search for a report on master where a Brillig report does not exist. On this branch we have a reference report on `mv/brillig-opcode-report`. I think we could merge `mv/brillig-opcode-report` into master and then any more commit hash updates for the `noir-gates-diff` repo can be made on this PR. ## Additional Context ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --------- Co-authored-by: Tom French <[email protected]>
- Loading branch information
1 parent
d4e2f0a
commit 6440e80
Showing
9 changed files
with
158 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
name: Report Brillig bytecode size diff | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
jobs: | ||
build-nargo: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
target: [x86_64-unknown-linux-gnu] | ||
|
||
steps: | ||
- name: Checkout Noir repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup toolchain | ||
uses: dtolnay/[email protected] | ||
|
||
- uses: Swatinem/rust-cache@v2 | ||
with: | ||
key: ${{ matrix.target }} | ||
cache-on-failure: true | ||
save-if: ${{ github.event_name != 'merge_group' }} | ||
|
||
- name: Build Nargo | ||
run: cargo build --package nargo_cli --release | ||
|
||
- name: Package artifacts | ||
run: | | ||
mkdir dist | ||
cp ./target/release/nargo ./dist/nargo | ||
7z a -ttar -so -an ./dist/* | 7z a -si ./nargo-x86_64-unknown-linux-gnu.tar.gz | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: nargo | ||
path: ./dist/* | ||
retention-days: 3 | ||
|
||
compare_brillig_bytecode_size_reports: | ||
needs: [build-nargo] | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: write | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Download nargo binary | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: nargo | ||
path: ./nargo | ||
|
||
- name: Set nargo on PATH | ||
run: | | ||
nargo_binary="${{ github.workspace }}/nargo/nargo" | ||
chmod +x $nargo_binary | ||
echo "$(dirname $nargo_binary)" >> $GITHUB_PATH | ||
export PATH="$PATH:$(dirname $nargo_binary)" | ||
nargo -V | ||
- name: Generate Brillig bytecode size report | ||
working-directory: ./test_programs | ||
run: | | ||
chmod +x gates_report_brillig.sh | ||
./gates_report_brillig.sh | ||
mv gates_report_brillig.json ../gates_report_brillig.json | ||
- name: Compare Brillig bytecode size reports | ||
id: brillig_bytecode_diff | ||
uses: noir-lang/noir-gates-diff@3fb844067b25d1b59727ea600b614503b33503f4 | ||
with: | ||
report: gates_report_brillig.json | ||
header: | | ||
# Changes to Brillig bytecode sizes | ||
brillig_report: true | ||
summaryQuantile: 0.9 # only display the 10% most significant bytecode size diffs in the summary (defaults to 20%) | ||
|
||
- name: Add bytecode size diff to sticky comment | ||
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target' | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
header: brillig | ||
# delete the comment in case changes no longer impact brillig bytecode sizes | ||
delete: ${{ !steps.brillig_bytecode_diff.outputs.markdown }} | ||
message: ${{ steps.brillig_bytecode_diff.outputs.markdown }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
test_programs/execution_success/brillig_loop_size_regression/Nargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "brillig_loop_size_regression" | ||
type = "bin" | ||
authors = [""] | ||
compiler_version = ">=0.33.0" | ||
|
||
[dependencies] |
Empty file.
16 changes: 16 additions & 0 deletions
16
test_programs/execution_success/brillig_loop_size_regression/src/main.nr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
struct EnumEmulation { | ||
a: Option<Field>, | ||
b: Option<Field>, | ||
c: Option<Field>, | ||
} | ||
|
||
unconstrained fn main() -> pub Field { | ||
let mut emulated_enum = EnumEmulation { a: Option::some(1), b: Option::none(), c: Option::none() }; | ||
|
||
for _ in 0..1 { | ||
assert_eq(emulated_enum.a.unwrap(), 1); | ||
} | ||
|
||
emulated_enum.a = Option::some(2); | ||
emulated_enum.a.unwrap() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
# These tests are incompatible with gas reporting | ||
excluded_dirs=("workspace" "workspace_default_member" "double_verify_nested_proof" "overlapping_dep_and_mod" "comptime_println") | ||
|
||
current_dir=$(pwd) | ||
base_path="$current_dir/execution_success" | ||
test_dirs=$(ls $base_path) | ||
|
||
# We generate a Noir workspace which contains all of the test cases | ||
# This allows us to generate a gates report using `nargo info` for all of them at once. | ||
|
||
echo "[workspace]" > Nargo.toml | ||
echo "members = [" >> Nargo.toml | ||
|
||
for dir in $test_dirs; do | ||
if [[ " ${excluded_dirs[@]} " =~ " ${dir} " ]]; then | ||
continue | ||
fi | ||
|
||
if [[ ${CI-false} = "true" ]] && [[ " ${ci_excluded_dirs[@]} " =~ " ${dir} " ]]; then | ||
continue | ||
fi | ||
|
||
echo " \"execution_success/$dir\"," >> Nargo.toml | ||
done | ||
|
||
echo "]" >> Nargo.toml | ||
|
||
nargo info --force-brillig --json > gates_report_brillig.json | ||
|
||
rm Nargo.toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters