-
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(brillig): Brillig entry point analysis and function specialization through duplication #7277
fix(brillig): Brillig entry point analysis and function specialization through duplication #7277
Conversation
…ultiple entry points
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.
⚠️ 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: b807d0d | Previous: 64890c0 | Ratio |
---|---|---|---|
noir-lang_noir_bigcurve_ |
311 s |
250 s |
1.24 |
This comment was automatically generated by workflow using github-action-benchmark.
CC: @TomAFrench
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 👇
|
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: b807d0d | Previous: 64890c0 | Ratio |
---|---|---|---|
AztecProtocol_aztec-packages_noir-projects_aztec-nr |
33 s |
34 s |
0.97 |
AztecProtocol_aztec-packages_noir-projects_noir-contracts |
71 s |
73 s |
0.97 |
AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_blob |
62 s |
66 s |
0.94 |
AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_private-kernel-lib |
167 s |
165 s |
1.01 |
AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_reset-kernel-lib |
11 s |
10 s |
1.10 |
AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_rollup-lib |
180 s |
171 s |
1.05 |
AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_types |
54 s |
53 s |
1.02 |
noir-lang_noir-bignum_ |
357 s |
363 s |
0.98 |
noir-lang_noir_bigcurve_ |
311 s |
250 s |
1.24 |
noir-lang_noir_json_parser_ |
9 s |
11 s |
0.82 |
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: b807d0d | Previous: 64890c0 | Ratio |
---|---|---|---|
private-kernel-inner |
275.6 MB |
275.6 MB |
1 |
private-kernel-reset |
586.9 MB |
586.93 MB |
1.00 |
private-kernel-tail |
199.21 MB |
199.2 MB |
1.00 |
rollup-base-private |
950.6 MB |
950.65 MB |
1.00 |
rollup-base-public |
816.14 MB |
816.16 MB |
1.00 |
rollup-block-root-empty |
326.24 MB |
326.23 MB |
1.00 |
rollup-block-root-single-tx |
6860 MB |
6860 MB |
1 |
rollup-block-root |
6870 MB |
6870 MB |
1 |
rollup-merge |
324.64 MB |
324.64 MB |
1 |
rollup-root |
372.32 MB |
372.3 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.
Looks good, I think we can streamline the logic a little bit before merging however.
Feel free to bump the execution time limit a little bit here. |
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
Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
* 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 <tom@tomfren.ch>
Description
Problem*
Resolves #7306.
The description in this PR repeats a lot of the comments and tests from the new SSA pass, but I have copied things here for visibility.
Take this program:
We have this SSA before Brillig gen:
For each entry point we will generate the follows artifacts for globals initialization:
It is then not clear to
inner_func
which map of SSA value id -> Brillig global initialization we should use.Without the hack from #7306 we get the following bytecode for f3:
This works when f3 is called from the f2 entry point. But it will break when called from the f1 entry point. We need to specialize f3 to account for the potentially conflicting global allocation maps.
Summary*
We now specialize functions per entry point.
A few things were done in this PR:
used_globals
map is set during DIE. Perhaps we do not have to re-run this though as the global value IDs should not change across SSA passes. I could foresee the CFG simplification after DIE leading to some terminators that use globals being removed and needing to recompute the used globals map. Perhaps we could recompute this during CFG simplification. I feel this can be done in a followup PR though.Additional Context
This works further re-iterates the need for a debug/release mode as laid out in #2128. This duplication can lead to code bloat. During debug mode we could potentially not perform any entry point analysis and just have the same globals across all functions if this work is shown to seriously degrade compilation. Then during release mode we can perform the full entry point analysis to optimize for runtime.
Documentation*
Check one:
PR Checklist*
cargo fmt
on default settings.