-
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
feat: simplify simple conditionals for brillig #7205
base: master
Are you sure you want to change the base?
Conversation
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 'Execution Memory'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20
.
Benchmark suite | Current: b1d908a | Previous: 32f05f4 | Ratio |
---|---|---|---|
`` | 652.28 MB |
213.15 MB |
3.06 |
`` | 793.63 MB |
213.15 MB |
3.72 |
`` | 555.92 MB |
213.15 MB |
2.61 |
`` | 1230 MB |
213.15 MB |
5.77 |
`` | 529.89 MB |
213.15 MB |
2.49 |
`` | 555.9 MB |
213.15 MB |
2.61 |
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 'Test Suite Duration'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20
.
Benchmark suite | Current: afe6213 | Previous: 9ae3c6c | Ratio |
---|---|---|---|
AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_blob |
64 s |
53 s |
1.21 |
This comment was automatically generated by workflow using github-action-benchmark.
CC: @TomAFrench
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 👇
|
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 'Execution Time'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20
.
Benchmark suite | Current: 06d26db | Previous: a9e9850 | Ratio |
---|---|---|---|
global_var_regression_entry_points |
0.009 s |
0.007 s |
1.29 |
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.
Did an initial scan. Do you know why we are regressing in brillig_conditional
?
if mapping.contains_key(k) { | ||
unreachable!("cannot merge key"); | ||
} | ||
if mapping.contains_key(v) { |
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.
We want to check contains_key
for the value 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.
No, if the two mapping both map to the same value, I think that's fine.
However, if the value of one is the key of the other, then one mapping is somehow overwriting what the other mapping is doing, and I disallow this. Especially because mappings are constructed in reverse order, so a mapping overwriting the 'next one' is probably bad.
BinaryOp::Lt => 5, | ||
BinaryOp::And | ||
| BinaryOp::Or | ||
| BinaryOp::Xor => 1, //todo |
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.
This TODO doesn't have a description and there are a couple TODOs in this function. Could you make issues to handle them if we are not going to in this PR?
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.
Happy to address these in this PR. The point is to provide realistic brillig cost for each opcode. The idea is to improve execution speed so the cost should be the runtime cost in whatever unit as along as it is the same for all opcodes. My numbers can certainly be improved.
I added a warning instead of a todo at the beginning of the function to indicate that the numbers are estimates and can be improved.
Agreed that it would be good to have more clarity on this. We've got some serious benefits when conditionally mutating large structs but there's quite a few regressions. |
I am not sure where these numbers come exactly, doing nargo info on brillig_conditional, I get 31 opcodes with the simplification VS 32 without: brillig_conditional | conditional | N/A | N/A | 32 | |
The regression is in the number of opcodes executed (i.e. the execution trace length). This can be shown by |
Oh right, then this is expected, since the optimisation execute both branches, it is expected to get more opcode executed, it's just that we avoid jumping around. For a number of cases, the numbers are better because of handling of arrays |
| Instruction::EnableSideEffectsIf { .. } | ||
| Instruction::IncrementRc { .. } | ||
| Instruction::DecrementRc { .. } | ||
| Instruction::MakeArray { .. } |
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.
We want to get a more accurate instruction count here. MakeArray is either several store and add instructions or a runtime loop for large non-nested arrays
if item_count > 10 |
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.
I put 20 as the cost then, since it seems to be the maximum cost (10 stores and ~10 index increments)
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 Memory'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20
.
Benchmark suite | Current: b1d908a | Previous: 32f05f4 | Ratio |
---|---|---|---|
`` | 587.75 MB |
272.08 MB |
2.16 |
`` | 1170 MB |
272.08 MB |
4.30 |
`` | 2180 MB |
272.08 MB |
8.01 |
`` | 662.72 MB |
272.08 MB |
2.44 |
`` | 547.13 MB |
272.08 MB |
2.01 |
`` | 5310 MB |
272.08 MB |
19.52 |
`` | 5320 MB |
272.08 MB |
19.55 |
`` | 545.56 MB |
272.08 MB |
2.01 |
`` | 662.73 MB |
272.08 MB |
2.44 |
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: 88faf2c | Previous: 819a53a | Ratio |
---|---|---|---|
private-kernel-inner |
2.404 s |
1.958 s |
1.23 |
This comment was automatically generated by workflow using github-action-benchmark.
CC: @TomAFrench
Description
Problem*
Resolves #6394
Summary*
Add a pass which simplify simple if statements in brillig functions
Additional Context
The PR is working fine now, the memory consumption alert does not seem to be up-to-date.
The report from the last commit is correct: https://github.com/noir-lang/noir/actions/runs/13119725684/artifacts/2528887358
Documentation*
Check one:
PR Checklist*
cargo fmt
on default settings.