feat: avoid overflow check when subtracting from a value that is the maximum for its bitsize#8190
Merged
TomAFrench merged 5 commits intomasterfrom Apr 24, 2025
Conversation
f562b2c to
80a5fd9
Compare
Contributor
There was a problem hiding this comment.
ACVM Benchmarks
Details
| Benchmark suite | Current: 8c591f1 | Previous: b411121 | Ratio |
|---|---|---|---|
purely_sequential_opcodes |
267999 ns/iter (± 439) |
268194 ns/iter (± 1126) |
1.00 |
perfectly_parallel_opcodes |
239165 ns/iter (± 662) |
239140 ns/iter (± 6124) |
1.00 |
perfectly_parallel_batch_inversion_opcodes |
3233929 ns/iter (± 14329) |
3579542 ns/iter (± 18839) |
0.90 |
This comment was automatically generated by workflow using github-action-benchmark.
Contributor
There was a problem hiding this comment.
Compilation Time
Details
| Benchmark suite | Current: 8c591f1 | Previous: b411121 | Ratio |
|---|---|---|---|
regression_4709 |
0.683 s |
0.646 s |
1.06 |
ram_blowup_regression |
13 s |
12.6 s |
1.03 |
global_var_regression_entry_points |
0.468 s |
0.468 s |
1 |
private-kernel-inner |
2.258 s |
2.148 s |
1.05 |
private-kernel-reset |
6.372 s |
6.808 s |
0.94 |
private-kernel-tail |
1.025 s |
1.022 s |
1.00 |
rollup-base-private |
18.26 s |
17.94 s |
1.02 |
rollup-base-public |
13.46 s |
13.72 s |
0.98 |
rollup-block-root-empty |
0.869 s |
0.879 s |
0.99 |
rollup-block-root-single-tx |
120 s |
121 s |
0.99 |
rollup-block-root |
119 s |
119 s |
1 |
rollup-merge |
0.877 s |
0.847 s |
1.04 |
rollup-root |
1.388 s |
1.406 s |
0.99 |
This comment was automatically generated by workflow using github-action-benchmark.
Contributor
There was a problem hiding this comment.
Execution Time
Details
| Benchmark suite | Current: 8c591f1 | Previous: b411121 | Ratio |
|---|---|---|---|
private-kernel-inner |
0.03 s |
0.028 s |
1.07 |
private-kernel-reset |
0.161 s |
0.162 s |
0.99 |
private-kernel-tail |
0.017 s |
0.017 s |
1 |
rollup-base-private |
0.334 s |
0.336 s |
0.99 |
rollup-base-public |
0.214 s |
0.214 s |
1 |
rollup-block-root |
11.3 s |
12 s |
0.94 |
rollup-merge |
0.004 s |
0.004 s |
1 |
rollup-root |
0.013 s |
0.013 s |
1 |
This comment was automatically generated by workflow using github-action-benchmark.
Contributor
There was a problem hiding this comment.
Execution Memory
Details
| Benchmark suite | Current: 8c591f1 | Previous: b411121 | Ratio |
|---|---|---|---|
private-kernel-inner |
203.28 MB |
203.28 MB |
1 |
private-kernel-reset |
227.03 MB |
227.03 MB |
1 |
private-kernel-tail |
181.3 MB |
181.3 MB |
1 |
rollup-base-private |
433.5 MB |
433.5 MB |
1 |
rollup-base-public |
425.68 MB |
425.68 MB |
1 |
rollup-block-root |
1420 MB |
1420 MB |
1 |
rollup-merge |
254.29 MB |
254.29 MB |
1 |
rollup-root |
260.03 MB |
260.03 MB |
1 |
This comment was automatically generated by workflow using github-action-benchmark.
Contributor
There was a problem hiding this comment.
Compilation Memory
Details
| Benchmark suite | Current: 8c591f1 | Previous: b411121 | Ratio |
|---|---|---|---|
private-kernel-inner |
270.78 MB |
270.86 MB |
1.00 |
private-kernel-reset |
535.37 MB |
535.37 MB |
1 |
private-kernel-tail |
200.11 MB |
200.14 MB |
1.00 |
rollup-base-private |
1330 MB |
1330 MB |
1 |
rollup-base-public |
1350 MB |
1350 MB |
1 |
rollup-block-root-empty |
270.76 MB |
270.76 MB |
1 |
rollup-block-root-single-tx |
7770 MB |
7770 MB |
1 |
rollup-block-root |
7780 MB |
7780 MB |
1 |
rollup-merge |
271.95 MB |
271.93 MB |
1.00 |
rollup-root |
322.45 MB |
322.45 MB |
1 |
This comment was automatically generated by workflow using github-action-benchmark.
Contributor
There was a problem hiding this comment.
Test Suite Duration
Details
| Benchmark suite | Current: 8c591f1 | Previous: b411121 | Ratio |
|---|---|---|---|
test_report_AztecProtocol_aztec-packages_noir-projects_aztec-nr |
49 s |
49 s |
1 |
test_report_AztecProtocol_aztec-packages_noir-projects_noir-contracts |
91 s |
90 s |
1.01 |
test_report_AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_blob |
38 s |
40 s |
0.95 |
test_report_AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_private-kernel-lib |
176 s |
175 s |
1.01 |
test_report_AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_rollup-lib |
154 s |
155 s |
0.99 |
test_report_AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_types |
52 s |
52 s |
1 |
test_report_noir-lang_noir-bignum_ |
414 s |
413 s |
1.00 |
test_report_noir-lang_noir_bigcurve_ |
288 s |
245 s |
1.18 |
test_report_noir-lang_sha512_ |
29 s |
27 s |
1.07 |
This comment was automatically generated by workflow using github-action-benchmark.
TomAFrench
approved these changes
Apr 24, 2025
github-merge-queue bot
pushed a commit
to AztecProtocol/aztec-packages
that referenced
this pull request
Apr 28, 2025
Automated pull of nightly from the [noir](https://github.com/noir-lang/noir) programming language, a dependency of Aztec. BEGIN_COMMIT_OVERRIDE feat: let `nargo test` use the new greybox fuzzer (noir-lang/noir#8234) chore(docs): add fixed bugs to list (noir-lang/noir#8201) fix(parser): do not use `Ident::default()` (noir-lang/noir#8224) feat(fuzz): Add experimental comptime code generator (noir-lang/noir#8207) fix: let SSA parser parse calls to print (noir-lang/noir#8232) feat: added 1, -1 case for inversions in brillig (noir-lang/noir#8225) chore: clippy (noir-lang/noir#8220) fix: don't take implicitly added named generics when checking where clauses (noir-lang/noir#8184) chore(docs): Defunctionalization and some minor cleanup (noir-lang/noir#8217) feat: add `--no-fuzz` and `--only-fuzz` to `nargo test` (noir-lang/noir#8213) chore: add regression test for panic encountered in bigcurve library. (noir-lang/noir#8211) fix: validate numeric types when passing them to a FunctionBuilder (noir-lang/noir#8215) chore: refactor constrainedness checks on trait impls (noir-lang/noir#8170) chore(test): Add smoke test for AST generation (noir-lang/noir#8048) chore: bump more dependencies (noir-lang/noir#8208) chore: Don't use `i1` in the AST fuzzer (noir-lang/noir#8204) fix: Do not panic if RHS constant in division has more bits than the operand (noir-lang/noir#8197) chore: bump cargo deps (noir-lang/noir#8205) fix: Handle truncating constants to 128 bits (noir-lang/noir#8180) fix!: disallow the `i1` type (noir-lang/noir#8172) chore(fuzz): Make sure `main` makes at least one call (noir-lang/noir#8202) fix: Use `get_local_or_global_instruction` in `try_optimize_array_set_from_previous_get` (noir-lang/noir#8200) fix: returns 0 for right shift overflow (noir-lang/noir#8189) feat: avoid overflow check when subtracting from a value that is the maximum for its bitsize (noir-lang/noir#8190) feat: optimize `checked_to_unchecked` to take into account multiplications (noir-lang/noir#8188) chore: document ssa `inline_simple_functions` (noir-lang/noir#8169) chore(docs): remove_unreachable SSA pass (noir-lang/noir#8196) chore: Change AST fuzzer recursion limit (noir-lang/noir#8173) chore(acir): Unify how we display witness indices (noir-lang/noir#8192) fix: Detect ABI change of fuzzing harnesses (noir-lang/noir#8193) chore(acir): Test that `BLACKBOX::RANGE` display the number of bits (noir-lang/noir#8191) fix(debugger): send idle at loop end + fix test (noir-lang/noir#8187) fix: Use `get_local_or_global_instruction` when simplifying `IfElse` (noir-lang/noir#8185) fix(parser): avoid using `Location::dummy()` (noir-lang/noir#8178) chore: Push a bug list (noir-lang/noir#8186) feat(greybox_fuzzer): Should_fail and should_fail_with (noir-lang/noir#8118) chore: move unsigned overflow check from acir/brillig to ssa (noir-lang/noir#8163) feat: location tree for debug_info (noir-lang/noir#7034) fix: Use `IntegerConstant` for loop boundaries in `unrolling` (noir-lang/noir#8094) fix(ssa): Recursive shared Brillig entry points (noir-lang/noir#8099) chore: enable '--pedantic-solving' on more tests (noir-lang/noir#7701) chore(readme): Update `acvm-repo` READMEs (noir-lang/noir#8150) chore(test): add `test_programs` dir for expected-panic tests (noir-lang/noir#8147) chore(docs): minor updates in solidity doc (noir-lang/noir#8160) feat(debugger): debug test functions (noir-lang/noir#7958) chore: migrate recursive proof test to ultrahonk (noir-lang/noir#8038) chore: bump glob package (noir-lang/noir#8159) chore: bump external pinned commits (noir-lang/noir#8139) chore(docs): patch web app tutorial in 1.0.0-beta3 versioned docs (noir-lang/noir#8158) END_COMMIT_OVERRIDE --------- Co-authored-by: AztecBot <tech@aztecprotocol.com> Co-authored-by: Ary Borenszweig <asterite@gmail.com> Co-authored-by: TomAFrench <tom@tomfren.ch>
github-merge-queue bot
pushed a commit
to AztecProtocol/aztec-packages
that referenced
this pull request
Apr 28, 2025
Automated pull of nightly from the [noir](https://github.com/noir-lang/noir) programming language, a dependency of Aztec. BEGIN_COMMIT_OVERRIDE feat: let `nargo test` use the new greybox fuzzer (noir-lang/noir#8234) chore(docs): add fixed bugs to list (noir-lang/noir#8201) fix(parser): do not use `Ident::default()` (noir-lang/noir#8224) feat(fuzz): Add experimental comptime code generator (noir-lang/noir#8207) fix: let SSA parser parse calls to print (noir-lang/noir#8232) feat: added 1, -1 case for inversions in brillig (noir-lang/noir#8225) chore: clippy (noir-lang/noir#8220) fix: don't take implicitly added named generics when checking where clauses (noir-lang/noir#8184) chore(docs): Defunctionalization and some minor cleanup (noir-lang/noir#8217) feat: add `--no-fuzz` and `--only-fuzz` to `nargo test` (noir-lang/noir#8213) chore: add regression test for panic encountered in bigcurve library. (noir-lang/noir#8211) fix: validate numeric types when passing them to a FunctionBuilder (noir-lang/noir#8215) chore: refactor constrainedness checks on trait impls (noir-lang/noir#8170) chore(test): Add smoke test for AST generation (noir-lang/noir#8048) chore: bump more dependencies (noir-lang/noir#8208) chore: Don't use `i1` in the AST fuzzer (noir-lang/noir#8204) fix: Do not panic if RHS constant in division has more bits than the operand (noir-lang/noir#8197) chore: bump cargo deps (noir-lang/noir#8205) fix: Handle truncating constants to 128 bits (noir-lang/noir#8180) fix!: disallow the `i1` type (noir-lang/noir#8172) chore(fuzz): Make sure `main` makes at least one call (noir-lang/noir#8202) fix: Use `get_local_or_global_instruction` in `try_optimize_array_set_from_previous_get` (noir-lang/noir#8200) fix: returns 0 for right shift overflow (noir-lang/noir#8189) feat: avoid overflow check when subtracting from a value that is the maximum for its bitsize (noir-lang/noir#8190) feat: optimize `checked_to_unchecked` to take into account multiplications (noir-lang/noir#8188) chore: document ssa `inline_simple_functions` (noir-lang/noir#8169) chore(docs): remove_unreachable SSA pass (noir-lang/noir#8196) chore: Change AST fuzzer recursion limit (noir-lang/noir#8173) chore(acir): Unify how we display witness indices (noir-lang/noir#8192) fix: Detect ABI change of fuzzing harnesses (noir-lang/noir#8193) chore(acir): Test that `BLACKBOX::RANGE` display the number of bits (noir-lang/noir#8191) fix(debugger): send idle at loop end + fix test (noir-lang/noir#8187) fix: Use `get_local_or_global_instruction` when simplifying `IfElse` (noir-lang/noir#8185) fix(parser): avoid using `Location::dummy()` (noir-lang/noir#8178) chore: Push a bug list (noir-lang/noir#8186) feat(greybox_fuzzer): Should_fail and should_fail_with (noir-lang/noir#8118) chore: move unsigned overflow check from acir/brillig to ssa (noir-lang/noir#8163) feat: location tree for debug_info (noir-lang/noir#7034) fix: Use `IntegerConstant` for loop boundaries in `unrolling` (noir-lang/noir#8094) fix(ssa): Recursive shared Brillig entry points (noir-lang/noir#8099) chore: enable '--pedantic-solving' on more tests (noir-lang/noir#7701) chore(readme): Update `acvm-repo` READMEs (noir-lang/noir#8150) chore(test): add `test_programs` dir for expected-panic tests (noir-lang/noir#8147) chore(docs): minor updates in solidity doc (noir-lang/noir#8160) feat(debugger): debug test functions (noir-lang/noir#7958) chore: migrate recursive proof test to ultrahonk (noir-lang/noir#8038) chore: bump glob package (noir-lang/noir#8159) chore: bump external pinned commits (noir-lang/noir#8139) chore(docs): patch web app tutorial in 1.0.0-beta3 versioned docs (noir-lang/noir#8158) END_COMMIT_OVERRIDE --------- Co-authored-by: AztecBot <tech@aztecprotocol.com> Co-authored-by: Ary Borenszweig <asterite@gmail.com> Co-authored-by: TomAFrench <tom@tomfren.ch>
github-merge-queue bot
pushed a commit
to AztecProtocol/aztec-packages
that referenced
this pull request
Apr 28, 2025
Automated pull of nightly from the [noir](https://github.com/noir-lang/noir) programming language, a dependency of Aztec. BEGIN_COMMIT_OVERRIDE feat: let `nargo test` use the new greybox fuzzer (noir-lang/noir#8234) chore(docs): add fixed bugs to list (noir-lang/noir#8201) fix(parser): do not use `Ident::default()` (noir-lang/noir#8224) feat(fuzz): Add experimental comptime code generator (noir-lang/noir#8207) fix: let SSA parser parse calls to print (noir-lang/noir#8232) feat: added 1, -1 case for inversions in brillig (noir-lang/noir#8225) chore: clippy (noir-lang/noir#8220) fix: don't take implicitly added named generics when checking where clauses (noir-lang/noir#8184) chore(docs): Defunctionalization and some minor cleanup (noir-lang/noir#8217) feat: add `--no-fuzz` and `--only-fuzz` to `nargo test` (noir-lang/noir#8213) chore: add regression test for panic encountered in bigcurve library. (noir-lang/noir#8211) fix: validate numeric types when passing them to a FunctionBuilder (noir-lang/noir#8215) chore: refactor constrainedness checks on trait impls (noir-lang/noir#8170) chore(test): Add smoke test for AST generation (noir-lang/noir#8048) chore: bump more dependencies (noir-lang/noir#8208) chore: Don't use `i1` in the AST fuzzer (noir-lang/noir#8204) fix: Do not panic if RHS constant in division has more bits than the operand (noir-lang/noir#8197) chore: bump cargo deps (noir-lang/noir#8205) fix: Handle truncating constants to 128 bits (noir-lang/noir#8180) fix!: disallow the `i1` type (noir-lang/noir#8172) chore(fuzz): Make sure `main` makes at least one call (noir-lang/noir#8202) fix: Use `get_local_or_global_instruction` in `try_optimize_array_set_from_previous_get` (noir-lang/noir#8200) fix: returns 0 for right shift overflow (noir-lang/noir#8189) feat: avoid overflow check when subtracting from a value that is the maximum for its bitsize (noir-lang/noir#8190) feat: optimize `checked_to_unchecked` to take into account multiplications (noir-lang/noir#8188) chore: document ssa `inline_simple_functions` (noir-lang/noir#8169) chore(docs): remove_unreachable SSA pass (noir-lang/noir#8196) chore: Change AST fuzzer recursion limit (noir-lang/noir#8173) chore(acir): Unify how we display witness indices (noir-lang/noir#8192) fix: Detect ABI change of fuzzing harnesses (noir-lang/noir#8193) chore(acir): Test that `BLACKBOX::RANGE` display the number of bits (noir-lang/noir#8191) fix(debugger): send idle at loop end + fix test (noir-lang/noir#8187) fix: Use `get_local_or_global_instruction` when simplifying `IfElse` (noir-lang/noir#8185) fix(parser): avoid using `Location::dummy()` (noir-lang/noir#8178) chore: Push a bug list (noir-lang/noir#8186) feat(greybox_fuzzer): Should_fail and should_fail_with (noir-lang/noir#8118) chore: move unsigned overflow check from acir/brillig to ssa (noir-lang/noir#8163) feat: location tree for debug_info (noir-lang/noir#7034) fix: Use `IntegerConstant` for loop boundaries in `unrolling` (noir-lang/noir#8094) fix(ssa): Recursive shared Brillig entry points (noir-lang/noir#8099) chore: enable '--pedantic-solving' on more tests (noir-lang/noir#7701) chore(readme): Update `acvm-repo` READMEs (noir-lang/noir#8150) chore(test): add `test_programs` dir for expected-panic tests (noir-lang/noir#8147) chore(docs): minor updates in solidity doc (noir-lang/noir#8160) feat(debugger): debug test functions (noir-lang/noir#7958) chore: migrate recursive proof test to ultrahonk (noir-lang/noir#8038) chore: bump glob package (noir-lang/noir#8159) chore: bump external pinned commits (noir-lang/noir#8139) chore(docs): patch web app tutorial in 1.0.0-beta3 versioned docs (noir-lang/noir#8158) END_COMMIT_OVERRIDE --------- Co-authored-by: AztecBot <tech@aztecprotocol.com> Co-authored-by: Ary Borenszweig <asterite@gmail.com> Co-authored-by: TomAFrench <tom@tomfren.ch>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Problem
No issue, just another optimization I thought of.
Summary
For example here:
https://github.com/noir-lang/noir-bignum/blob/ff2db6058cfe5906d60edcac1c89a9935bc688d2/src/fns/constrained_ops.nr#L185
We have
1 - more_than_N_minus_one_limbswheremore_than_N_minus_one_limbsis a boolean that was turned intou32. In this case it can never overflow. That's what this PR does but it generalizes this to any bit size (probably not very useful, but still...)Additional Context
Documentation
Check one:
PR Checklist
cargo fmton default settings.