-
Notifications
You must be signed in to change notification settings - Fork 236
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
feat(brillig): Hoist shared constants across functions to the global space #7216
base: master
Are you sure you want to change the base?
Conversation
…brillig space. Done on the Brillig side
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.
⚠️ 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: 2940cc3 | Previous: 15bbaa8 | Ratio |
---|---|---|---|
noir-lang_noir_check_shuffle_ |
1 s |
0 s |
+∞ |
This comment was automatically generated by workflow using github-action-benchmark.
CC: @TomAFrench
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 'Compilation Time'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20
.
Benchmark suite | Current: 40c3b5b | Previous: 49d1b13 | Ratio |
---|---|---|---|
sha256_regression |
1.23 s |
0.977 s |
1.26 |
regression_4709 |
1.04 s |
0.845 s |
1.23 |
global_var_regression_entry_points |
0.74 s |
0.566 s |
1.31 |
This comment was automatically generated by workflow using github-action-benchmark.
CC: @TomAFrench
compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs
Outdated
Show resolved
Hide resolved
compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block.rs
Outdated
Show resolved
Hide resolved
compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_block_variables.rs
Outdated
Show resolved
Hide resolved
compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_globals.rs
Outdated
Show resolved
Hide resolved
compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_globals.rs
Outdated
Show resolved
Hide resolved
test_programs/execution_success/global_var_regression_simple/src/main.nr
Show resolved
Hide resolved
compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_globals.rs
Outdated
Show resolved
Hide resolved
compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_globals.rs
Outdated
Show resolved
Hide resolved
Can you explain a bit more on why we don't place these hoisted constants into the main globals map? We should be able to treat them in exactly the same way. |
I decided to do it during Brillig for a few reasons aside this being a Brillig unique operation.
Due to the above reasons, I felt we could do this as part of Brillig gen rather than having to alter the pre-existing SSA. I had considered placing them in the main globals map as well, but ultimately decided to trade-off a new "type" of global and a little extra complexity in Brillig to avoid extra complexity in the SSA passes (most likely it would be constant folding that would be updated) for this Brillig unique feature. |
Description
Problem*
Resolves #7109
Summary*
Before compiling Brillig globals we run an analysis to see which constants are shared across multiple functions. Those values are allocated along with the user-defined globals and then special cased when compiling regular functions. Any repeat constants across functions should be a part of the global read-only memory space and will live throughout the program.
BrilligGlobals
context structure we now maintain a new map:ConstantAllocation
to determine which constant appears in both functions. This was technically recomputed as we calculate aConstantAllocation
when creating aFunctionContext
. For now, I decided to recompute it as it has a minor affect on compilation, but just noting this is a place of optimization in the future.dfg.is_global
.Additional Context
Documentation*
Check one:
PR Checklist*
cargo fmt
on default settings.