-
Notifications
You must be signed in to change notification settings - Fork 219
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
chore: Add Instruction::DecrementRc
#4525
Conversation
Changes to circuit sizes
🧾 Summary (10% most significant diffs)
Full diff report 👇
|
This seems to be a considerable improvement for pathological cases at least. Here's an example: unconstrained fn main() {
let mut array = [0; 10000];
for i in 0 .. array.len() {
array[i] = i;
// This increments the reference count of `array` on each iteration,
// tanking performance even though the `array2` parameter of `foo`:
// 1. is not returned, so its lifetime should not prevent the mutation of `array`
// 2. is not itself mutable
foo(array);
}
}
unconstrained fn foo<N>(_array2: [u64; N]) {} On master this runs in |
Not sure why the |
Fixed it here #4531 |
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.
Let's see if we get some nice speedups!
Removing this from the queue to investigate why |
I'm still unable to find why poseidonsponge_x5_254 has bloated so much. Oddly enough, the SSA is actually shorter for the version on this branch than in master. The most I've confirmed so far is that it is due to the new DecrementRc instructions rather than the changed location of the IncrementRc instructions from call arguments to function parameters. I'm not sure why this is though, given both of these are ignored in acir-gen and this test only uses acir functions. |
Found the culprit with @vezenovm's help. IncRc was special cased in the DIE pass but dec rc was not. This lead to dec_rc's values getting counted as used and they weren't eliminated from the program as a result. |
Now we actually have an improvement in one case :D |
* master: chore: separate tests for execution failures from compilation failures (#4559) feat: remove curly braces with fmt (#4529) fix: Make `nargo` the default binary for cargo run (#4554) fix: Evaluate operators in globals in types (#4537) chore: Add more `Hash` impls to stdlib (#4470) feat: Sync from aztec-packages (#4546) chore: Add `Instruction::DecrementRc` (#4525) feat: add `nargo compile --watch` command (#4464) fix: Substitute generics when checking the field count of a type (#4547) feat: optimize sha2 implementation (#4441)
Description
Problem*
Resolves #4522
Summary*
Experimenting with this to see how much it improves performance of unconstrained code using arrays.
Additional Context
Currently the new dec_rc instruction is only issued for function parameters when a function is finished - assuming the parameters are not also returned.
CC @sirasistant for visibility
Documentation*
Check one:
PR Checklist*
cargo fmt
on default settings.