fix(ownership): Increment reference count for nested array get in LHS assignment#9347
fix(ownership): Increment reference count for nested array get in LHS assignment#9347
Conversation
Changes to number of Brillig opcodes executed
🧾 Summary (10% most significant diffs)
Full diff report 👇
|
Changes to Brillig bytecode sizes
🧾 Summary (10% most significant diffs)
Full diff report 👇
|
There was a problem hiding this comment.
⚠️ Performance Alert ⚠️
Possible performance regression was detected for benchmark 'Test Suite Duration'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.
| Benchmark suite | Current: 5785ece | Previous: 08a955c | Ratio |
|---|---|---|---|
test_report_zkpassport_noir-ecdsa_ |
3 s |
1 s |
3 |
This comment was automatically generated by workflow using github-action-benchmark.
CC: @TomAFrench
jfecher
left a comment
There was a problem hiding this comment.
One of the goals of the ownership pass was to have all clones be explicit so they are easier to track compared to before when it was unclear when something was getting cloned.
Looking at the lvalue of b$l0[0][0] = G_B$g0[1].clone()[0].clone() and the fact we always inc_rc now in a nested array get, can you instead add a Clone node in the LValue enum that we always issue for nested array gets during the ownership pass instead?
|
Resolves #9368 |
|
I'm about to push some more new snapshots updates, in case anyone is also doing the same. There are a couple of failures but I think they are in tests that explicitly check what the reference count is at runtime, and these might have changed because of this PR... so they should be easy to fix. |
|
Not sure what's going on with "Brillig execution trace sizes"... |
|
If we're going to merge this, can you update the timeouts to avoid CI failing? |
jfecher
left a comment
There was a problem hiding this comment.
Blocking this while I investigate why the lvalue change caused brillig opcodes executed to increase so dramatically
Automated pull of nightly from the [noir](https://github.com/noir-lang/noir) programming language, a dependency of Aztec. BEGIN_COMMIT_OVERRIDE chore: Release Noir(1.0.0-beta.10) (noir-lang/noir#9311) feat(ssa_fuzzer): arrays support (noir-lang/noir#9427) chore: add link to issue on TODOs (noir-lang/noir#8307) fix(ownership): Increment reference count for nested array get in LHS assignment (noir-lang/noir#9347) chore: add some mem2reg unit tests (noir-lang/noir#9405) chore(as_slice_length): Various unit tests (noir-lang/noir#9419) chore(simplify_cfg): Additional unit tests (noir-lang/noir#9426) chore: create directory when writing witness artefact (noir-lang/noir#9383) fix: throw error if foreign call returns the wrong number of fields (noir-lang/noir#9286) chore: update ex in docs (noir-lang/noir#9385) chore: add some `assert_constant` tests (noir-lang/noir#9413) chore: error on non constant inputs for Pedersen generators (noir-lang/noir#9389) chore(inlining): Unit tests for global values and conditional inlining (noir-lang/noir#9411) chore(ssa_fuzzer): refactor fuzzing modes + add fuzzing mode without DIE pass (noir-lang/noir#9401) chore(inlining): Various unit tests (noir-lang/noir#9388) feat(ssa_fuzzer): pushing generated program and witness to redis queue (noir-lang/noir#9375) fix(ssa_gen): Generate code for index before the collection (noir-lang/noir#9332) chore: Regression test for calling a mutable closure inside a mutable closure (noir-lang/noir#9384) fix: some nargo expand fixes (noir-lang/noir#9324) fix: disable comptime printing when requesting json output (noir-lang/noir#9381) chore: address TODO comments (noir-lang/noir#9379) feat: type alias for numeric generics (noir-lang/noir#7583) chore: bump external pinned commits (noir-lang/noir#9291) END_COMMIT_OVERRIDE --------- Co-authored-by: AztecBot <tech@aztecprotocol.com> Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
Description
Problem*
Resolves #9270
Alternative to #9341
This is the AST we send to SSA gen:
This produces the following SSA:
Details
We appropriately clone
g8but that does not mean we updated the RCs of the internal arrays. So when we dov19 = array_get v18, index u32 0 -> [[u8; 2]; 1]the internal array has a ref count of one and we mutate it. So then b[0][0] gets changed to "EN" but so doesG_B.Summary*
It felt weird to "clone" the lhs assignment, as we don't necessarily want to clone
b. We want to increment its RC because it is shared with another array pointer which is the array we actually want to clone. Thus, I chose to increment the RC during SSA gen when extracting the current value of the LHS for an assignment.Additional Context
Documentation*
Check one:
PR Checklist*
cargo fmton default settings.