-
Notifications
You must be signed in to change notification settings - Fork 244
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): Brilig entry point analysis and function specialization through duplication #7277
base: master
Are you sure you want to change the base?
fix(brillig): Brilig 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: a850ec0 | Previous: 25b989f | Ratio |
---|---|---|---|
AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_types |
71 s |
52 s |
1.37 |
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 👇
|
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.