-
Notifications
You must be signed in to change notification settings - Fork 213
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
fix: optimizer to keep track of changing opcode locations #6781
Merged
Conversation
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
aakoshh
changed the title
Fix optimizer to keep track of changing opcode locations
fix: optimizer to keep track of changing opcode locations
Dec 12, 2024
Peak Memory Sample
|
Compilation Sample
|
…/noir into fix-optimizer-opcode-locations
asterite
approved these changes
Dec 12, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
AztecBot
added a commit
to AztecProtocol/aztec-packages
that referenced
this pull request
Dec 13, 2024
…iant code motion (noir-lang/noir#6782) feat: add `(x | 1)` optimization for booleans (noir-lang/noir#6795) feat: `nargo test -q` (or `nargo test --format terse`) (noir-lang/noir#6776) fix: disable failure persistance in nargo test fuzzing (noir-lang/noir#6777) feat(cli): Verify `return` against ABI and `Prover.toml` (noir-lang/noir#6765) chore(ssa): Activate loop invariant code motion on ACIR functions (noir-lang/noir#6785) fix: use extension in docs link so it also works on GitHub (noir-lang/noir#6787) fix: optimizer to keep track of changing opcode locations (noir-lang/noir#6781) fix: Minimal change to avoid reverting entire PR #6685 (noir-lang/noir#6778)
AztecBot
added a commit
to AztecProtocol/aztec-packages
that referenced
this pull request
Dec 13, 2024
…tion (noir-lang/noir#6782) feat: add `(x | 1)` optimization for booleans (noir-lang/noir#6795) feat: `nargo test -q` (or `nargo test --format terse`) (noir-lang/noir#6776) fix: disable failure persistance in nargo test fuzzing (noir-lang/noir#6777) feat(cli): Verify `return` against ABI and `Prover.toml` (noir-lang/noir#6765) chore(ssa): Activate loop invariant code motion on ACIR functions (noir-lang/noir#6785) fix: use extension in docs link so it also works on GitHub (noir-lang/noir#6787) fix: optimizer to keep track of changing opcode locations (noir-lang/noir#6781) fix: Minimal change to avoid reverting entire PR #6685 (noir-lang/noir#6778)
This was referenced Dec 13, 2024
TomAFrench
added a commit
that referenced
this pull request
Dec 14, 2024
* master: (313 commits) chore: Do not print entire functions when running debug trace (#6814) chore(ci): Active rollup circuits in compilation report (#6813) feat(ssa): Bring back tracking of RC instructions during DIE (#6783) feat: add `nargo test --format json` (#6796) chore: Change Id to use a u32 (#6807) feat(ssa): Hoist MakeArray instructions during loop invariant code motion (#6782) feat: add `(x | 1)` optimization for booleans (#6795) feat: `nargo test -q` (or `nargo test --format terse`) (#6776) fix: disable failure persistance in nargo test fuzzing (#6777) feat(cli): Verify `return` against ABI and `Prover.toml` (#6765) chore(ssa): Activate loop invariant code motion on ACIR functions (#6785) fix: use extension in docs link so it also works on GitHub (#6787) fix: optimizer to keep track of changing opcode locations (#6781) fix: Minimal change to avoid reverting entire PR #6685 (#6778) feat: several `nargo test` improvements (#6728) chore: Try replace callstack with a linked list (#6747) chore: Use `NumericType` not `Type` for casts and numeric constants (#6769) chore(ci): Extend compiler memory report to external repos (#6768) chore(ci): Handle external libraries in compilation timing report (#6750) feat(ssa): Implement missing brillig constraints SSA check (#6658) ...
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*
Resolves the issue found trying to merge AztecProtocol/aztec-packages#10483
Mirroring the commits added to that PR.
Summary*
Unlike
transform_internal
,optimize_internal
did not take anacir_opcode_positions
which would have allowed it to be chained. This caused the second iteration of the loop to resetacir_opcode_positions
to the default values, which indicated no change when theAcirTransformationMap
was derived from it. The consequence was that theassert_messages
anddebug
information did not align with the new opcode locations, which changed in the first iteration.Also changed
test_cmd
to apply thenargo::ops::transform
optimisations, so we get to see any problems introduced there come up in tests. This actually brought out this regression invecdequeue
test, where an unexpected assertion message was returned.Added an integration test to provoke the error fixed by the PR. In order for the ACIR not to eliminate all operations due to them working with constants known in the test code, I am calling it through the fuzzer, which makes the test look silly. To make it work required an update to the fuzz tester to anticipate tests that expect failures.
Additional Context
The way to debug this on
aztec-packages
went like this.First build everything with
./bootstrap.sh
, then in one terminal start an oracle:In another terminal run a test (one of the failing ones):
Then change something in the Noir codebase and recompile:
cd aztec-packages/noir ./bootstrap.sh
With
const MAX_OPTIMIZER_PASSES: usize = 1;
the test passed, otherwise failed. TheLOG_LEVEL=debug
showed the index of the failing opcode. Curiously it was the same in both tests (the oracle is expected to fail, the test verifies it fails with the right message).One of the things I tried was to print the ACIR opcodes with, with a change in the code so it prints the optimised version, after transformations:
Comparing the ACIR indicated that 1 or 3 passes doesn't make any difference. Since it was also the same opcode, I started to suspect that it is actually the assertion message that gets lost.
With this fix the contract tests pass.
Documentation*
Check one:
PR Checklist*
cargo fmt
on default settings.