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: 52a64ff | Previous: 3629a25 | Ratio |
|---|---|---|---|
test_report_zkpassport_noir_rsa_ |
2 s |
1 s |
2 |
This comment was automatically generated by workflow using github-action-benchmark.
CC: @TomAFrench
There was a problem hiding this comment.
The SSA produced by mem2reg is technically valid so we shouldn't have to fix it after the fact. In general, we shouldn't rely on other SSA passes to fix corner cases in previous passes either since this makes them more brittle.
I think the actual issue here is that the interpreter errors at all for this code. It errors because side effects are disabled for that branch in flattening and we return Value::uninitialized for a reference type which currently does not give a default value to the resulting reference. We should change Value::uninitialized to recur in the case of references to store an uninitialized reference element to that reference as well. Then the code should run.
That being said, there are some brillig improvements to adding this pass so I'd be okay with merging it once the other change is made so we can confirm it works without the pass and if we are okay with the tradeoff of a bit more compilation time for these brillig improvements.
|
@jfecher I changed However, In the case of this integration test, similar to the description of that PR, we will have the
Although technically that would be wrong, since |
|
@aakoshh it sounds like remove_unreachable_instructions produces invalid SSA then. Regardless of the value for |
|
Okay, I'll have a look at undoing that change then. |
There was a problem hiding this comment.
ACVM Benchmarks
Details
| Benchmark suite | Current: 61f614f | Previous: 3629a25 | Ratio |
|---|---|---|---|
purely_sequential_opcodes |
248426 ns/iter (± 976) |
249317 ns/iter (± 1414) |
1.00 |
perfectly_parallel_opcodes |
217858 ns/iter (± 2016) |
218311 ns/iter (± 1895) |
1.00 |
perfectly_parallel_batch_inversion_opcodes |
2780914 ns/iter (± 10320) |
2776515 ns/iter (± 30609) |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
|
@aakoshh I'm not sure if it needs to be undone entirely - maybe it could be changed to also store a default value to the element? |
|
Yeah that's what I was thinking as well: insert a |
There was a problem hiding this comment.
Execution Time
Details
| Benchmark suite | Current: 61f614f | Previous: 5657704 | Ratio |
|---|---|---|---|
private-kernel-inner |
0.015 s |
0.014 s |
1.07 |
private-kernel-reset |
0.153 s |
0.154 s |
0.99 |
private-kernel-tail |
0.01 s |
0.01 s |
1 |
rollup-base-private |
0.267 s |
0.265 s |
1.01 |
rollup-base-public |
0.16 s |
0.171 s |
0.94 |
rollup-block-root |
13.2 s |
13.4 s |
0.99 |
rollup-merge |
0.002 s |
0.002 s |
1 |
rollup-root |
0.004 s |
0.004 s |
1 |
semaphore-depth-10 |
0.019 s |
0.019 s |
1 |
sha512-100-bytes |
0.102 s |
0.098 s |
1.04 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Opcode count
Details
| Benchmark suite | Current: 61f614f | Previous: 5657704 | Ratio |
|---|---|---|---|
private-kernel-inner |
14792 opcodes |
14792 opcodes |
1 |
private-kernel-reset |
68868 opcodes |
68868 opcodes |
1 |
private-kernel-tail |
11177 opcodes |
11177 opcodes |
1 |
rollup-base-private |
221335 opcodes |
221335 opcodes |
1 |
rollup-base-public |
159954 opcodes |
159954 opcodes |
1 |
rollup-block-root-empty |
68106 opcodes |
68106 opcodes |
1 |
rollup-block-root-single-tx |
964509 opcodes |
964513 opcodes |
1.00 |
rollup-block-root |
965795 opcodes |
965799 opcodes |
1.00 |
rollup-merge |
1409 opcodes |
1409 opcodes |
1 |
rollup-root |
2631 opcodes |
2631 opcodes |
1 |
semaphore-depth-10 |
5700 opcodes |
5700 opcodes |
1 |
sha512-100-bytes |
13173 opcodes |
13173 opcodes |
1 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Compilation Time
Details
| Benchmark suite | Current: 61f614f | Previous: 5657704 | Ratio |
|---|---|---|---|
private-kernel-inner |
1.716 s |
1.728 s |
0.99 |
private-kernel-reset |
7.746 s |
7.996 s |
0.97 |
private-kernel-tail |
1.456 s |
1.328 s |
1.10 |
rollup-base-private |
16.54 s |
15.58 s |
1.06 |
rollup-base-public |
13.1 s |
13.74 s |
0.95 |
rollup-block-root-empty |
19.78 s |
20.82 s |
0.95 |
rollup-block-root-single-tx |
188 s |
187 s |
1.01 |
rollup-block-root |
182 s |
191 s |
0.95 |
rollup-merge |
1.322 s |
1.358 s |
0.97 |
rollup-root |
1.584 s |
1.438 s |
1.10 |
semaphore-depth-10 |
0.813 s |
0.781 s |
1.04 |
sha512-100-bytes |
1.582 s |
1.601 s |
0.99 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Artifact Size
Details
| Benchmark suite | Current: 61f614f | Previous: 5657704 | Ratio |
|---|---|---|---|
private-kernel-inner |
708.9 KB |
708.9 KB |
1 |
private-kernel-reset |
2032.2 KB |
2032.5 KB |
1.00 |
private-kernel-tail |
535.2 KB |
535.2 KB |
1 |
rollup-base-private |
4319.6 KB |
4319.6 KB |
1 |
rollup-base-public |
3332 KB |
3332 KB |
1 |
rollup-block-root-empty |
3846.6 KB |
3847.1 KB |
1.00 |
rollup-block-root-single-tx |
30744.8 KB |
30747.8 KB |
1.00 |
rollup-block-root |
30775.7 KB |
30780.5 KB |
1.00 |
rollup-merge |
187 KB |
187 KB |
1 |
rollup-root |
388.8 KB |
388.9 KB |
1.00 |
semaphore-depth-10 |
631.5 KB |
631.5 KB |
1 |
sha512-100-bytes |
525.5 KB |
525.5 KB |
1 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Test Suite Duration
Details
| Benchmark suite | Current: 61f614f | Previous: 5657704 | Ratio |
|---|---|---|---|
test_report_AztecProtocol_aztec-packages_noir-projects_aztec-nr |
97 s |
97 s |
1 |
test_report_AztecProtocol_aztec-packages_noir-projects_noir-contracts |
108 s |
108 s |
1 |
test_report_AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_blob |
158 s |
150 s |
1.05 |
test_report_AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_private-kernel-lib |
205 s |
207 s |
0.99 |
test_report_AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_reset-kernel-lib |
32 s |
32 s |
1 |
test_report_AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_rollup-lib |
552 s |
||
test_report_AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_types |
102 s |
102 s |
1 |
test_report_noir-lang_noir-bignum_ |
232 s |
467 s |
0.50 |
test_report_noir-lang_noir_bigcurve_ |
292 s |
310 s |
0.94 |
test_report_noir-lang_sha256_ |
15 s |
14 s |
1.07 |
test_report_noir-lang_sha512_ |
14 s |
13 s |
1.08 |
test_report_zkpassport_noir-ecdsa_ |
2 s |
2 s |
1 |
test_report_zkpassport_noir_rsa_ |
2 s |
2 s |
1 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Execution Memory
Details
| Benchmark suite | Current: 61f614f | Previous: 3629a25 | Ratio |
|---|---|---|---|
private-kernel-inner |
206.72 MB |
206.72 MB |
1 |
private-kernel-reset |
243.53 MB |
243.53 MB |
1 |
private-kernel-tail |
195.94 MB |
195.94 MB |
1 |
rollup-base-private |
500.25 MB |
500.25 MB |
1 |
rollup-base-public |
432.9 MB |
432.9 MB |
1 |
rollup-block-root |
1500 MB |
1500 MB |
1 |
rollup-merge |
328.19 MB |
328.19 MB |
1 |
rollup-root |
330.55 MB |
330.55 MB |
1 |
semaphore_depth_10 |
69.5 MB |
69.5 MB |
1 |
sha512_100_bytes |
54.99 MB |
54.99 MB |
1 |
This comment was automatically generated by workflow using github-action-benchmark.
There was a problem hiding this comment.
Compilation Memory
Details
| Benchmark suite | Current: 61f614f | Previous: 3629a25 | Ratio |
|---|---|---|---|
private-kernel-inner |
239.63 MB |
239.64 MB |
1.00 |
private-kernel-reset |
549.09 MB |
549.1 MB |
1.00 |
private-kernel-tail |
213.85 MB |
213.85 MB |
1 |
rollup-base-private |
1350 MB |
1350 MB |
1 |
rollup-base-public |
1400 MB |
1400 MB |
1 |
rollup-block-root-empty |
1010 MB |
1090 MB |
0.93 |
rollup-block-root-single-tx |
9520 MB |
9580 MB |
0.99 |
rollup-block-root |
9520 MB |
9590 MB |
0.99 |
rollup-merge |
330.56 MB |
330.56 MB |
1 |
rollup-root |
341.25 MB |
341.34 MB |
1.00 |
semaphore_depth_10 |
104.75 MB |
104.76 MB |
1.00 |
sha512_100_bytes |
233.05 MB |
233.16 MB |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
Value::uninitialized
Value::uninitialized Value::uninitialized for references in the SSA interpreter
compiler/noirc_evaluator/src/ssa/opt/.remove_unreachable_instructions.rs.pending-snap
Outdated
Show resolved
Hide resolved
Co-authored-by: jfecher <jfecher11@gmail.com>
…lang/noir into af/9594-fix-empty-slice-flattening
Automated pull of nightly from the [noir](https://github.com/noir-lang/noir) programming language, a dependency of Aztec. BEGIN_COMMIT_OVERRIDE fix: don't thread-bomb unnecessarily (noir-lang/noir#9643) chore(mem2reg): Only add to per function last_loads if load is not removed (noir-lang/noir#9647) chore(mem2reg): add a few regression tests (noir-lang/noir#9615) fix: Monomorphize function values as pairs of `(constrained, unconstrained)` (noir-lang/noir#9484) fix(mem2reg): Mark block parameters with unknown alias sets in presence of nested references (noir-lang/noir#9629) fix(ssa): Put some default in `Value::uninitialized` for references in the SSA interpreter (noir-lang/noir#9603) feat(ssa_fuzzer): ecdsa blackbox functions (noir-lang/noir#9584) fix(mem2reg): missing alias from block parameter to its argument (noir-lang/noir#9640) fix(acir_gen): A slice might be a nested Array, not a flattened DynamicArray (noir-lang/noir#9600) chore: add another mem2reg regression for #9613 (noir-lang/noir#9635) chore: document remove_if_else (in preparation for audit) (noir-lang/noir#9621) fix(mem2reg): Assume all function reference parameters have an unknown alias set with nested references (noir-lang/noir#9632) chore: add a regression test for #9613 (noir-lang/noir#9630) fix: Revert "feat(mem2reg): address last known value is independent of its… (noir-lang/noir#9628) fix(inlining): Do not inline globals and lower them during ACIR gen (noir-lang/noir#9626) chore(brillig): Include function name with `--count-array-copies` debug information (noir-lang/noir#9623) chore: use `assert_ssa_does_not_change` throughout all SSA tests (noir-lang/noir#9625) chore: only run remove_paired_rc in brillig functions (noir-lang/noir#9624) chore: some inlining refactors (noir-lang/noir#9622) chore(mem2reg): avoid redundant PostOrder computation (noir-lang/noir#9620) chore: bump external pinned commits (noir-lang/noir#9618) chore: document intrinsics (noir-lang/noir#9382) fix: Make inc/dec_rc impure (noir-lang/noir#9617) chore: greenlight `checked_to_unchecked` for audits (noir-lang/noir#9537) feat(mem2reg): address last known value is independent of its aliases (noir-lang/noir#9613) fix: Fix if-else alias in mem2reg (noir-lang/noir#9611) END_COMMIT_OVERRIDE
Automated pull of nightly from the [noir](https://github.com/noir-lang/noir) programming language, a dependency of Aztec. BEGIN_COMMIT_OVERRIDE fix: don't thread-bomb unnecessarily (noir-lang/noir#9643) chore(mem2reg): Only add to per function last_loads if load is not removed (noir-lang/noir#9647) chore(mem2reg): add a few regression tests (noir-lang/noir#9615) fix: Monomorphize function values as pairs of `(constrained, unconstrained)` (noir-lang/noir#9484) fix(mem2reg): Mark block parameters with unknown alias sets in presence of nested references (noir-lang/noir#9629) fix(ssa): Put some default in `Value::uninitialized` for references in the SSA interpreter (noir-lang/noir#9603) feat(ssa_fuzzer): ecdsa blackbox functions (noir-lang/noir#9584) fix(mem2reg): missing alias from block parameter to its argument (noir-lang/noir#9640) fix(acir_gen): A slice might be a nested Array, not a flattened DynamicArray (noir-lang/noir#9600) chore: add another mem2reg regression for #9613 (noir-lang/noir#9635) chore: document remove_if_else (in preparation for audit) (noir-lang/noir#9621) fix(mem2reg): Assume all function reference parameters have an unknown alias set with nested references (noir-lang/noir#9632) chore: add a regression test for #9613 (noir-lang/noir#9630) fix: Revert "feat(mem2reg): address last known value is independent of its… (noir-lang/noir#9628) fix(inlining): Do not inline globals and lower them during ACIR gen (noir-lang/noir#9626) chore(brillig): Include function name with `--count-array-copies` debug information (noir-lang/noir#9623) chore: use `assert_ssa_does_not_change` throughout all SSA tests (noir-lang/noir#9625) chore: only run remove_paired_rc in brillig functions (noir-lang/noir#9624) chore: some inlining refactors (noir-lang/noir#9622) chore(mem2reg): avoid redundant PostOrder computation (noir-lang/noir#9620) chore: bump external pinned commits (noir-lang/noir#9618) chore: document intrinsics (noir-lang/noir#9382) fix: Make inc/dec_rc impure (noir-lang/noir#9617) chore: greenlight `checked_to_unchecked` for audits (noir-lang/noir#9537) feat(mem2reg): address last known value is independent of its aliases (noir-lang/noir#9613) fix: Fix if-else alias in mem2reg (noir-lang/noir#9611) END_COMMIT_OVERRIDE
Automated pull of nightly from the [noir](https://github.com/noir-lang/noir) programming language, a dependency of Aztec. BEGIN_COMMIT_OVERRIDE fix: don't thread-bomb unnecessarily (noir-lang/noir#9643) chore(mem2reg): Only add to per function last_loads if load is not removed (noir-lang/noir#9647) chore(mem2reg): add a few regression tests (noir-lang/noir#9615) fix: Monomorphize function values as pairs of `(constrained, unconstrained)` (noir-lang/noir#9484) fix(mem2reg): Mark block parameters with unknown alias sets in presence of nested references (noir-lang/noir#9629) fix(ssa): Put some default in `Value::uninitialized` for references in the SSA interpreter (noir-lang/noir#9603) feat(ssa_fuzzer): ecdsa blackbox functions (noir-lang/noir#9584) fix(mem2reg): missing alias from block parameter to its argument (noir-lang/noir#9640) fix(acir_gen): A slice might be a nested Array, not a flattened DynamicArray (noir-lang/noir#9600) chore: add another mem2reg regression for #9613 (noir-lang/noir#9635) chore: document remove_if_else (in preparation for audit) (noir-lang/noir#9621) fix(mem2reg): Assume all function reference parameters have an unknown alias set with nested references (noir-lang/noir#9632) chore: add a regression test for #9613 (noir-lang/noir#9630) fix: Revert "feat(mem2reg): address last known value is independent of its… (noir-lang/noir#9628) fix(inlining): Do not inline globals and lower them during ACIR gen (noir-lang/noir#9626) chore(brillig): Include function name with `--count-array-copies` debug information (noir-lang/noir#9623) chore: use `assert_ssa_does_not_change` throughout all SSA tests (noir-lang/noir#9625) chore: only run remove_paired_rc in brillig functions (noir-lang/noir#9624) chore: some inlining refactors (noir-lang/noir#9622) chore(mem2reg): avoid redundant PostOrder computation (noir-lang/noir#9620) chore: bump external pinned commits (noir-lang/noir#9618) chore: document intrinsics (noir-lang/noir#9382) fix: Make inc/dec_rc impure (noir-lang/noir#9617) chore: greenlight `checked_to_unchecked` for audits (noir-lang/noir#9537) feat(mem2reg): address last known value is independent of its aliases (noir-lang/noir#9613) fix: Fix if-else alias in mem2reg (noir-lang/noir#9611) END_COMMIT_OVERRIDE
Automated pull of nightly from the [noir](https://github.com/noir-lang/noir) programming language, a dependency of Aztec. BEGIN_COMMIT_OVERRIDE fix: don't thread-bomb unnecessarily (noir-lang/noir#9643) chore(mem2reg): Only add to per function last_loads if load is not removed (noir-lang/noir#9647) chore(mem2reg): add a few regression tests (noir-lang/noir#9615) fix: Monomorphize function values as pairs of `(constrained, unconstrained)` (noir-lang/noir#9484) fix(mem2reg): Mark block parameters with unknown alias sets in presence of nested references (noir-lang/noir#9629) fix(ssa): Put some default in `Value::uninitialized` for references in the SSA interpreter (noir-lang/noir#9603) feat(ssa_fuzzer): ecdsa blackbox functions (noir-lang/noir#9584) fix(mem2reg): missing alias from block parameter to its argument (noir-lang/noir#9640) fix(acir_gen): A slice might be a nested Array, not a flattened DynamicArray (noir-lang/noir#9600) chore: add another mem2reg regression for #9613 (noir-lang/noir#9635) chore: document remove_if_else (in preparation for audit) (noir-lang/noir#9621) fix(mem2reg): Assume all function reference parameters have an unknown alias set with nested references (noir-lang/noir#9632) chore: add a regression test for #9613 (noir-lang/noir#9630) fix: Revert "feat(mem2reg): address last known value is independent of its… (noir-lang/noir#9628) fix(inlining): Do not inline globals and lower them during ACIR gen (noir-lang/noir#9626) chore(brillig): Include function name with `--count-array-copies` debug information (noir-lang/noir#9623) chore: use `assert_ssa_does_not_change` throughout all SSA tests (noir-lang/noir#9625) chore: only run remove_paired_rc in brillig functions (noir-lang/noir#9624) chore: some inlining refactors (noir-lang/noir#9622) chore(mem2reg): avoid redundant PostOrder computation (noir-lang/noir#9620) chore: bump external pinned commits (noir-lang/noir#9618) chore: document intrinsics (noir-lang/noir#9382) fix: Make inc/dec_rc impure (noir-lang/noir#9617) chore: greenlight `checked_to_unchecked` for audits (noir-lang/noir#9537) feat(mem2reg): address last known value is independent of its aliases (noir-lang/noir#9613) fix: Fix if-else alias in mem2reg (noir-lang/noir#9611) END_COMMIT_OVERRIDE
Description
Problem*
Resolves #9594
Summary*
Value::uninitializedin the SSA interpreter to storeSomedefault value forReferencetypes. This way a subsequentLoadwill not fail, which it currently does even if side effects are disabled, if the value has never been stored to.dead_instruction_eliminationafter the firstmem2regpass to get rid of anyLoadthat isn't actually needed. This isn't needed to fix the problem, but it was left in because it has some positive effects on the bytecode size.remove_unreachable_instructionsto insert astoreafter anallocateinzeroed_valuewhen replacing an instruction that returned a reference. This way aLoadin the interpreter won't fail if executed on the resulting SSA.Additional Context
In the integration test we have this code:
eis an empty slice, so indexing it with anything should fail. Howeverawill befalse, so we should not hit this problem.The SSA before the first
mem2regreflects the state where a constraint exists on the index, but it's not an always-fail one, and we never hit that block during evaluation:Note that
v17gets from the empty slice,v18loads the value of the reference, and then it'sstored atv4.After
mem2regthe constraint changes into an always-fail one, however this has no effect on the rest of the instructions in the block.mem2regalso removes thestore v18 at v4, but it cannot remove thev18 = load v17instruction.When we reach the flattening step, an
enable_side_effects v0appears before thearray_get:With the changes to the SSA Interpreter, this now returns a
0value in the reference, andload v11can succeed.DIE
Eventually the DIE pass removes this as it's not used. My observation was even though
mem2regcould not remove theload, since it removed thestore, if we run DIE now, it's also eliminated at an early stage (before flattening), when we are still in a position of evaluating only the blocks which are activated by the jumps.After the extra DIE pass, we have the following state:
This doesn't handle the case of dangling loads for values which are used; for those we still get a compilation error. It only brings forward the "healing" of the SSA by the DIE, so we don't get a period of SSA states which cannot be interpreted.
Remove Unreachable Instructions
If we disable the new DIE pass, then the Remove Unreachable Instructions pass handles the case in the following way:
Notice that
v11 = allocate -> &mut u1; store u1 0 at v11replaced thearray_getbecause of the conditional-fail constraints preceding it, and together the allowsload v11to be interpreted.Documentation*
Check one:
PR Checklist*
cargo fmton default settings.