Skip to content
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: remove 'single use' intermediate variables #6268

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

guipublic
Copy link
Contributor

Description

Problem*

Resolves #6085

Summary*

This PR tries to benefit from Barretenberg's 'big-add gates' support, which was enabled by PR AztecProtocol/aztec-packages#8960
It's a simple optimisation which removes intermediate variables usually created by the CSatTransformer if they are not re-used elsewhere.
The PR assumes that the backend is able to handle infinite width, but still requires the CSatTransformer, which is not really consistent. I plan to make follow-up PRs to get rid of this (but I can't guarantee it will work).

Additional Context

I tested the optimisation on all 'execution_sucess' test cases. In most cases, there were no change at all, while in some cases we would win one or two (10 max) on the circuit size.
However, in a few cases, listed below in the form "test case: circuit size with 'intermediate var' optimisation vs no optimisation", it can be more significant:

7_function: 2955 vs 2992
bit_shifts_runtime: 5451 vs 5761
eddsa: 65805 vs 70406
hashmap: 135023 vs 150661
nested_array_dynamic: 12594 vs 12922
nested_array_in_slice: 5371 vs 5449
poseidon_bn254_hash: 1028 vs 1060
poseidon_bn254_hash_width_3: 1028 vs 1495
poseidonsponge_x5_254: 1244 vs 1307
regression_5252: 76491 vs 83862
sha256_var_size_regression: 74093 vs 74529
sha2_byte: 93998 vs 94006
slice_dynamic_index: 6308 vs 6419
slices: 3835 vs 3874
to_be_bytes: 135 vs 143
to_bytes_consistent: 6 vs 51
to_bytes_integration: 434 vs 484
u128: 4662 vs 4707
u16_support: 3023 vs 3057

Documentation*

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [For Experimental Features] Documentation to be submitted in a separate PR.

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate usage of "big add" gates in the bb dsl folder
1 participant