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

chore: Separate unconstrained functions during monomorphization #6894

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

Conversation

jfecher
Copy link
Contributor

@jfecher jfecher commented Dec 20, 2024

Description

Problem*

Resolves #6841
Resolves #6831

Summary*

Adds a boolean is_unconstrained as an extra key during monomorphization. This should separate constrained from unconstrained functions. This key is infectious so every function called from an unconstrained function will also be unconstrained.

Additional Context

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.

Copy link
Contributor

github-actions bot commented Dec 20, 2024

Changes to Brillig bytecode sizes

Generated at commit: d0748c8ba7ff5ec6ee62cdcf940712bf0ebfc6e8, compared to commit: 326173d3b7fa19297baac7017f0c518e495696a4

🧾 Summary (10% most significant diffs)

Program Brillig opcodes (+/-) %
sha256_regression -13 ✅ -0.19%
higher_order_functions -598 ✅ -88.33%

Full diff report 👇
Program Brillig opcodes (+/-) %
sha256_var_padding_regression 5,123 (-6) -0.12%
sha256 2,404 (-4) -0.17%
sha256_regression 6,904 (-13) -0.19%
higher_order_functions 79 (-598) -88.33%

Copy link
Contributor

github-actions bot commented Dec 20, 2024

Peak Memory Sample

Program Peak Memory %
keccak256 78.48M 0%
workspace 123.58M 0%
regression_4709 422.91M 0%
ram_blowup_regression 1.58G 0%
rollup-base-public 10.47G 0%
rollup-base-private 6.57G 0%
private-kernel-tail 202.04M 0%
private-kernel-reset 716.67M -1%
private-kernel-inner 292.31M 0%
parity-root 172.14M 0%

Copy link
Contributor

github-actions bot commented Dec 20, 2024

Compilation Report

Program Compilation Time %
sha256_regression 1.327s -3%
regression_4709 0.788s -2%
ram_blowup_regression 15.145s -1%
rollup-root 4.202s 7%
rollup-block-merge 4.244s 10%
rollup-base-public 115.827s 4%
rollup-base-private 95.274s -2%
private-kernel-tail 1.036s -7%
private-kernel-reset 7.052s -5%
private-kernel-inner 2.228s 1%
parity-root 0.759s -7%
noir-contracts 83.448s -6%

Copy link
Contributor

github-actions bot commented Dec 20, 2024

Execution Report

Program Execution Time %
sha256_regression 0.591s -2%
regression_4709 0.385s -4%
ram_blowup_regression 3.881s -1%
rollup-root 2.155s -1%
rollup-block-merge 2.159s 2%
rollup-base-public 34.950s -1%
rollup-base-private 31.626s 0%
private-kernel-tail 0.749s -4%
private-kernel-reset 2.158s -1%
private-kernel-inner 1.248s 1%
parity-root 0.547s 2%

Copy link
Contributor

github-actions bot commented Jan 2, 2025

Changes to number of Brillig opcodes executed

Generated at commit: d0748c8ba7ff5ec6ee62cdcf940712bf0ebfc6e8, compared to commit: 326173d3b7fa19297baac7017f0c518e495696a4

🧾 Summary (10% most significant diffs)

Program Brillig opcodes (+/-) %
sha256_regression -141 ✅ -0.12%
higher_order_functions -1,144 ✅ -91.16%

Full diff report 👇
Program Brillig opcodes (+/-) %
sha256_var_padding_regression 222,210 (-6) -0.00%
sha256 14,992 (-4) -0.03%
sha256_regression 118,563 (-141) -0.12%
higher_order_functions 111 (-1,144) -91.16%

@jfecher jfecher marked this pull request as ready for review January 2, 2025 20:34
Copy link
Contributor

github-actions bot commented Jan 3, 2025

Execution Memory Report

Program Peak Memory
keccak256 74.61M
workspace 123.34M
regression_4709 315.93M
ram_blowup_regression 512.47M
rollup-base-public 3.05G
rollup-base-private 2.97G
private-kernel-tail 182.06M
private-kernel-reset 255.64M
private-kernel-inner 215.24M
parity-root 155.86M

Copy link
Contributor

github-actions bot commented Jan 3, 2025

Compilation Memory Report

Program Peak Memory %
keccak256 78.50M 0%
workspace 123.63M 0%
regression_4709 422.91M 0%
ram_blowup_regression 1.58G 0%
rollup-base-public 10.47G 0%
rollup-base-private 6.57G 0%
private-kernel-tail 202.02M 0%
private-kernel-reset 716.65M -1%
private-kernel-inner 292.29M 0%
parity-root 172.13M 0%

@jfecher
Copy link
Contributor Author

jfecher commented Jan 3, 2025

This should be ready for review now. There were some issues with unused functions before that have since been resolved. I've tried a few combinations including updating the defunctionalization pass to not touch acir functions, but I found that it was easiest to just remove unused functions again after inlining to avoid triggering a constant_assert in an unreachable function in the hashmap example.

@TomAFrench
Copy link
Member

This causes some regressions on circuit sizes which is not being shown due to a bug in the noir-gates-diff action. The fix is in #6944.

Copy link
Contributor

github-actions bot commented Jan 3, 2025

Changes to circuit sizes

Generated at commit: d0748c8ba7ff5ec6ee62cdcf940712bf0ebfc6e8, compared to commit: 326173d3b7fa19297baac7017f0c518e495696a4

🧾 Summary (10% most significant diffs)

Program ACIR opcodes (+/-) % Circuit size (+/-) %
array_dynamic_nested_blackbox_input -2 ✅ -0.79% -13 ✅ -0.18%
nested_array_dynamic -156 ✅ -4.44% -278 ✅ -2.13%

Full diff report 👇
Program ACIR opcodes (+/-) % Circuit size (+/-) %
array_dynamic_nested_blackbox_input 251 (-2) -0.79% 7,313 (-13) -0.18%
nested_array_dynamic 3,358 (-156) -4.44% 12,755 (-278) -2.13%

@TomAFrench
Copy link
Member

This causes some regressions on circuit sizes

Ah nice, looks like I was reading things backwards.

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.

Separate runtimes before SSA Strip IncRC instructions from SSA for ACIR functions before reaching ACIRgen
3 participants