-
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
feat(ssa): Bring back tracking of RC instructions during DIE #6783
Conversation
Changes to Brillig bytecode sizes
🧾 Summary (10% most significant diffs)
Full diff report 👇
|
Changes to number of Brillig opcodes executed
🧾 Summary (10% most significant diffs)
Full diff report 👇
|
Peak Memory Sample
|
Compilation Sample
|
Changes to circuit sizes
🧾 Summary (10% most significant diffs)
Full diff report 👇
|
Maybe it'd be easier if we promote this to its own pass rather than basing it off of DIE logic |
Perhaps, I was thinking the same thing as it makes DIE more complex. On the flip side, I wanted to avoid another pass for this logic which can be contained to DIE and in a way does remove useless instructions (even if they are not "dead"). |
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.
I'd like to see if this breaks an external repos if we change rcs to start at 1 again instead of 2. No errors in cargo test locally at least, but I'm checking in #6797 in the meantime.
This PR is where we get the largest benefit for patterns like this test where we are simply reading from a global array in a loop. |
My main hesitancy with this PR is that it was removed for correctness before and is re-added now but what changed? As far as I can tell it's identical. Won't we run into sync issues again? Or run into them once #6797 is added as well? |
This PR also adds a check for whether an array type was passed to a call in the block (previously we only checked for stores). I have also tested it here (AztecProtocol/aztec-packages#10399) which passes all noir-projects tests in atec-packages (the yarn-project-test failures look to be from the p2p network tests). It does look this PR would run into issues with #6797. But don't we have these issues already if we were to add back #6797? |
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.
Hmm alright, I'm okay with merging this then. Are you confident passing arrays into calls was the original issue or is this something we should continue investigating?
It does look this PR would run into issues with #6797. But don't we have these issues already if we were to add back #6797?
I'm not concerned with #6797, the only failure there was from the failure that was originally specific to that rc change rather than the RcTracker changes here.
Working with the original RC tracker (no I can continue trying to reproduce the exact Noir snippet from aztec-packages, but I do think not checking arrays passed to calls was the culprit of the broken RC tracker. |
That sounds good, didn't know you were able to reproduce an issue using reference_counts |
…race (noir-lang/noir#6814) chore(ci): Active rollup circuits in compilation report (noir-lang/noir#6813) feat(ssa): Bring back tracking of RC instructions during DIE (noir-lang/noir#6783)
* 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) ...
…race (noir-lang/noir#6814) chore(ci): Active rollup circuits in compilation report (noir-lang/noir#6813) feat(ssa): Bring back tracking of RC instructions during DIE (noir-lang/noir#6783)
…ang/noir#6814) chore(ci): Active rollup circuits in compilation report (noir-lang/noir#6813) feat(ssa): Bring back tracking of RC instructions during DIE (noir-lang/noir#6783)
Description
Problem*
Brings back the optimization with a fix that was removed for correctness
Summary*
This came to mind while working on #6782 as actually being a very beneficial optimization. After #6782 we will have multiple locations (loop invariant code motion and constant folding) where upon moving a make_array instructions, we will conservatively issue inc_rc instructions in case that array is mutable. However, if the array is never mutated or mutably borrowed that will lead to us unnecessary incrementing the reference counter.
Compared to the original RcTracker:
This lets us get rid of most increment rcs on arrays that are never mutated.
Additional Context
Documentation*
Check one:
PR Checklist*
cargo fmt
on default settings.