-
Notifications
You must be signed in to change notification settings - Fork 248
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(ssa): Accurately mark binary ops for hoisting and check Div/Mod against induction variable lower bound #7396
Conversation
… check induction var for div/mod
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 👇
|
Changes to circuit sizes
🧾 Summary (10% most significant diffs)
Full diff report 👇
|
To get these regressions back, we would need some way to determine that the predicate that the instruction is under is the same as the predicate of the loop pre-header. This is a bit simpler for ACIR after flattening and unrolling, but invariant code motion occurs before unrolling and is mostly needed for Brillig where we still have a CFG. |
Bug was introduced in this PR #6910. We look to have kept about half of the gains with this correction fix: |
Will add some more tests showing this explicitly. EDIT: Added an additional method to |
This is due to a new method to the |
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.
Execution Time
Benchmark suite | Current: b6b63a3 | Previous: 31cc6a1 | Ratio |
---|---|---|---|
private-kernel-inner |
0.071 s |
0.07 s |
1.01 |
private-kernel-reset |
0.3 s |
0.298 s |
1.01 |
private-kernel-tail |
0.018 s |
0.018 s |
1 |
rollup-base-private |
0.467 s |
0.467 s |
1 |
rollup-base-public |
0.189 s |
0.184 s |
1.03 |
rollup-block-root |
34.9 s |
||
rollup-merge |
0.007 s |
0.006 s |
1.17 |
rollup-root |
0.039 s |
0.039 s |
1 |
This comment was automatically generated by workflow using github-action-benchmark.
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.
Compilation Time
Benchmark suite | Current: b6b63a3 | Previous: 31cc6a1 | Ratio |
---|---|---|---|
sha256_regression |
0.955 s |
1.01 s |
0.95 |
regression_4709 |
0.748 s |
0.766 s |
0.98 |
ram_blowup_regression |
20.7 s |
21.2 s |
0.98 |
global_var_regression_entry_points |
0.606 s |
0.618 s |
0.98 |
private-kernel-inner |
2.134 s |
2.066 s |
1.03 |
private-kernel-reset |
6.458 s |
6.542 s |
0.99 |
private-kernel-tail |
0.998 s |
0.942 s |
1.06 |
rollup-base-private |
9.794 s |
9.102 s |
1.08 |
rollup-base-public |
5.158 s |
5.172 s |
1.00 |
rollup-block-root-empty |
0.958 s |
0.93 s |
1.03 |
rollup-block-root-single-tx |
94.9 s |
92.3 s |
1.03 |
rollup-block-root |
89 s |
||
rollup-merge |
0.927 s |
0.914 s |
1.01 |
rollup-root |
1.542 s |
1.524 s |
1.01 |
This comment was automatically generated by workflow using github-action-benchmark.
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.
Compilation Memory
Benchmark suite | Current: a1af2bf | Previous: 31cc6a1 | Ratio |
---|---|---|---|
private-kernel-inner |
275.62 MB |
275.6 MB |
1.00 |
private-kernel-reset |
586.93 MB |
586.93 MB |
1 |
private-kernel-tail |
199.2 MB |
199.21 MB |
1.00 |
rollup-base-private |
950.65 MB |
950.65 MB |
1 |
rollup-base-public |
816.27 MB |
816.18 MB |
1.00 |
rollup-block-root-empty |
326.22 MB |
326.24 MB |
1.00 |
rollup-block-root-single-tx |
6860 MB |
6860 MB |
1 |
rollup-block-root |
6870 MB |
6870 MB |
1 |
rollup-merge |
324.65 MB |
324.65 MB |
1 |
rollup-root |
372.32 MB |
372.31 MB |
1.00 |
This comment was automatically generated by workflow using github-action-benchmark.
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.
Execution Memory
Benchmark suite | Current: a1af2bf | Previous: 31cc6a1 | Ratio |
---|---|---|---|
private-kernel-inner |
214.85 MB |
214.85 MB |
1 |
private-kernel-reset |
249.37 MB |
249.37 MB |
1 |
private-kernel-tail |
184.8 MB |
184.8 MB |
1 |
rollup-base-private |
431.41 MB |
431.41 MB |
1 |
rollup-base-public |
370.16 MB |
370.16 MB |
1 |
rollup-block-root |
1410 MB |
1410 MB |
1 |
rollup-merge |
309.06 MB |
309.06 MB |
1 |
rollup-root |
316.45 MB |
316.45 MB |
1 |
This comment was automatically generated by workflow using github-action-benchmark.
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.
Test Suite Duration
Benchmark suite | Current: b6b63a3 | Previous: 31cc6a1 | Ratio |
---|---|---|---|
AztecProtocol_aztec-packages_noir-projects_aztec-nr |
33 s |
33 s |
1 |
AztecProtocol_aztec-packages_noir-projects_noir-contracts |
71 s |
72 s |
0.99 |
AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_blob |
55 s |
51 s |
1.08 |
AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_private-kernel-lib |
166 s |
165 s |
1.01 |
AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_reset-kernel-lib |
10 s |
10 s |
1 |
AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_rollup-lib |
166 s |
173 s |
0.96 |
AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_types |
56 s |
55 s |
1.02 |
noir-lang_noir-bignum_ |
358 s |
||
noir-lang_noir_bigcurve_ |
255 s |
288 s |
0.89 |
noir-lang_noir_json_parser_ |
12 s |
12 s |
1 |
This comment was automatically generated by workflow using github-action-benchmark.
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.
LGTM, small nit.
* master: fix(performance): Remove redundant slice access check from brillig (#7434) chore(docs): updating tutorials and other nits to beta.2 (#7405) feat: LSP hover for integer literals (#7368) feat(experimental): Compile match expressions (#7312) feat(acir_field): Add little-endian byte serialization for FieldElement (#7258) feat: allow unquoting TraitConstraint in trait impl position (#7395) feat(brillig): Hoist shared constants across functions to the global space (#7216) feat(LSP): auto-import via visible reexport (#7409) fix(brillig): Brillig entry point analysis and function specialization through duplication (#7277) chore: redo typo PR by maximevtush (#7425) fix(ssa): Accurately mark binary ops for hoisting and check Div/Mod against induction variable lower bound (#7396) feat!: remove bigint from stdlib (#7411)
…m brillig (noir-lang/noir#7434) chore(docs): updating tutorials and other nits to beta.2 (noir-lang/noir#7405) feat: LSP hover for integer literals (noir-lang/noir#7368) feat(experimental): Compile match expressions (noir-lang/noir#7312) feat(acir_field): Add little-endian byte serialization for FieldElement (noir-lang/noir#7258) feat: allow unquoting TraitConstraint in trait impl position (noir-lang/noir#7395) feat(brillig): Hoist shared constants across functions to the global space (noir-lang/noir#7216) feat(LSP): auto-import via visible reexport (noir-lang/noir#7409) fix(brillig): Brillig entry point analysis and function specialization through duplication (noir-lang/noir#7277) chore: redo typo PR by maximevtush (noir-lang/noir#7425) fix(ssa): Accurately mark binary ops for hoisting and check Div/Mod against induction variable lower bound (noir-lang/noir#7396) feat!: remove bigint from stdlib (noir-lang/noir#7411) chore: bump aztec-packages commit (noir-lang/noir#7415) chore: deprecate `merkle` module of stdlib (noir-lang/noir#7413) chore(ci): lock aztec-packages commit in CI (noir-lang/noir#7414) feat: while statement (noir-lang/noir#7280)
…oir-lang/noir#7434) chore(docs): updating tutorials and other nits to beta.2 (noir-lang/noir#7405) feat: LSP hover for integer literals (noir-lang/noir#7368) feat(experimental): Compile match expressions (noir-lang/noir#7312) feat(acir_field): Add little-endian byte serialization for FieldElement (noir-lang/noir#7258) feat: allow unquoting TraitConstraint in trait impl position (noir-lang/noir#7395) feat(brillig): Hoist shared constants across functions to the global space (noir-lang/noir#7216) feat(LSP): auto-import via visible reexport (noir-lang/noir#7409) fix(brillig): Brillig entry point analysis and function specialization through duplication (noir-lang/noir#7277) chore: redo typo PR by maximevtush (noir-lang/noir#7425) fix(ssa): Accurately mark binary ops for hoisting and check Div/Mod against induction variable lower bound (noir-lang/noir#7396) feat!: remove bigint from stdlib (noir-lang/noir#7411) chore: bump aztec-packages commit (noir-lang/noir#7415) chore: deprecate `merkle` module of stdlib (noir-lang/noir#7413) chore(ci): lock aztec-packages commit in CI (noir-lang/noir#7414) feat: while statement (noir-lang/noir#7280)
Automated pull of development from the [noir](https://github.com/noir-lang/noir) programming language, a dependency of Aztec. BEGIN_COMMIT_OVERRIDE fix(performance): Remove redundant slice access check from brillig (noir-lang/noir#7434) chore(docs): updating tutorials and other nits to beta.2 (noir-lang/noir#7405) feat: LSP hover for integer literals (noir-lang/noir#7368) feat(experimental): Compile match expressions (noir-lang/noir#7312) feat(acir_field): Add little-endian byte serialization for FieldElement (noir-lang/noir#7258) feat: allow unquoting TraitConstraint in trait impl position (noir-lang/noir#7395) feat(brillig): Hoist shared constants across functions to the global space (noir-lang/noir#7216) feat(LSP): auto-import via visible reexport (noir-lang/noir#7409) fix(brillig): Brillig entry point analysis and function specialization through duplication (noir-lang/noir#7277) chore: redo typo PR by maximevtush (noir-lang/noir#7425) fix(ssa): Accurately mark binary ops for hoisting and check Div/Mod against induction variable lower bound (noir-lang/noir#7396) feat!: remove bigint from stdlib (noir-lang/noir#7411) chore: bump aztec-packages commit (noir-lang/noir#7415) chore: deprecate `merkle` module of stdlib (noir-lang/noir#7413) chore(ci): lock aztec-packages commit in CI (noir-lang/noir#7414) feat: while statement (noir-lang/noir#7280) END_COMMIT_OVERRIDE --------- Co-authored-by: Tom French <[email protected]>
Description
Problem*
No issue but just a bug I found while working towards other tasks.
Summary*
We currently mark an invariant as being allowed for hoisting with the following:
This means we are currently allowing any Binary op to be hoisting if it is an invariant. We need to remove the
|| matches!(instruction, Instruction::Binary(_))
and rely oninstruction.can_be_deduplicated
andself.can_be_deduplicated_from_loop_bound
.This is an issue because if we were to have an operation that can potentially error (such as from overflow or div by zero) that was under a predicate, we would hoist that instruction out of the loop. If that predicate turns off the error (e.g. by protecting against a div by zero in user code) a user would still hit an error.
Additional Context
Documentation*
Check one:
PR Checklist*
cargo fmt
on default settings.