-
Notifications
You must be signed in to change notification settings - Fork 237
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): Globals entry point reachability analysis #7188
Conversation
…nerate full call graph recursively to get all globals
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
compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_globals.rs
Outdated
Show resolved
Hide resolved
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.
Generally looks good, some nits.
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
…ls.rs Co-authored-by: Tom French <[email protected]>
…ls.rs Co-authored-by: Tom French <[email protected]>
…ls.rs Co-authored-by: Tom French <[email protected]>
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: abdf7b9 | Previous: 784a562 | Ratio |
---|---|---|---|
sha256_regression |
1.27 s |
0.989 s |
1.28 |
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.
LGTM
chore: bump gates diff (noir-lang/noir#7245) feat: simplify subtraction from self to return zero (noir-lang/noir#7189) feat: allow specifying multiple patterns in nargo test (noir-lang/noir#7186) fix: Avoid type error when calling something with a type alias of a function (noir-lang/noir#7239) feat: Allow resolved types in constructors (noir-lang/noir#7223) chore: clarify to_radix docs examples (noir-lang/noir#7230) chore: fix struct example (noir-lang/noir#7198) feat(optimization): Add purity analysis to SSA (noir-lang/noir#7197) chore: start tracking time to run critical library tests (noir-lang/noir#7221) chore: Rework defunctionalize pass to not rely on DFG bugs (noir-lang/noir#7222) fix(brillig): Globals entry point reachability analysis (noir-lang/noir#7188) chore: update docs to use devcontainer feature (noir-lang/noir#7206) chore(ci): Add test for global vars entry points regression (noir-lang/noir#7209) chore(ssa): Flip the SSA Brillig constraint check to off by default (noir-lang/noir#7211) chore(docs): moving references to noir-starter to awesome-noir (noir-lang/noir#7203) chore: build docs in the merge queue (noir-lang/noir#7218) fix: correct reversed callstacks (noir-lang/noir#7212) chore: exclude dependency fetching time from benchmarks (noir-lang/noir#7210) feat(experimental): Support enums in comptime code (noir-lang/noir#7194)
Description
Problem*
Resolves #7158
Was not sure whether to label this as a feat or a fix. It fixes repeated global initialization across multiple Brillig entry points, however, it is a pretty meaningful change in how we generate globals so I thought about labelling it a feat. As I labelled the issue a bug I have used the fix prefix.
Summary*
We now track globals Brillig artifacts by their entry point rather than having a single globals artifact for all entry points.
A few changes have been made:
used_globals
by function rather than over the entire program.BrilligGlobals
context structure to simplify code gen for globals.BrilligGlobals
we create some initial state from the function call graph.brillig_entry_points
.inner_call_to_entry_point
GlobalInit
label has been updated to be associated with a function id representing an entry point. We now haveGlobalInit(entry_point: FunctionId)
.Additional Context
Most of the line additions are from the large global array included in
test_programs/execution_success/global_var_regression_entry_points/src/consts.nr
file. This change is most meaningful when tested with a large amount of globals across many entry points.I compiled
global_var_regression_entry_points
withnargo compile --force --inliner-aggressiveness -100000000000000
.Running
NOIR_LOG=trace nargo execute
looking atnargo::ops::execute: close time.busy
for multiple runs:On master:
~35ms
This PR:
~7ms
About a 5x improvement in this example.
Looking at the execution report for
rollup-block-root
we look to see a large benefit:This PR:
While on master we are at ~41s. So about a 12% improvement.
Documentation*
Check one:
PR Checklist*
cargo fmt
on default settings.