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

fix: Simplify defunctionalize return #7101

Merged

Conversation

aakoshh
Copy link
Contributor

@aakoshh aakoshh commented Jan 17, 2025

Description

Problem*

Extracted from #7072
Depends on #7100 to fix SSA parsing

Summary*

Skips the creation of unnecessary blocks in the apply functions during defunctionalize, jumping straight to the return block.

Additional Context

At the time I thought it might play a role in the inlining cost calculation, causing the apply to be too expensive to inline because it affects the weight. It turned out the function was too expensive to inline even with this change.

These blocks would be removed by a simplify pass, but I didn't see a reason they should be generated in the first place.

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 Jan 17, 2025

Compilation Report

Program Compilation Time %
sha256_regression 1.000s -3%
regression_4709 0.789s -1%
ram_blowup_regression 16.200s 0%
rollup-root 3.690s 6%
rollup-merge 2.064s 0%
rollup-block-root-single-tx 141.000s -3%
rollup-block-root-empty 2.052s 0%
rollup-block-root 137.000s 2%
rollup-block-merge 3.580s -2%
rollup-base-public 29.400s 6%
rollup-base-private 10.940s 9%
private-kernel-tail 1.002s 6%
private-kernel-reset 6.030s -4%
private-kernel-inner 1.940s 0%

Copy link
Contributor

github-actions bot commented Jan 17, 2025

Execution Report

Program Execution Time %
sha256_regression 0.051s 0%
regression_4709 0.001s 0%
ram_blowup_regression 0.610s 0%
rollup-root 0.106s 1%
rollup-merge 0.006s 0%
rollup-block-root 37.300s 0%
rollup-block-merge 0.105s 0%
rollup-base-public 1.231s 0%
rollup-base-private 0.455s 0%
private-kernel-tail 0.019s 5%
private-kernel-reset 0.311s -1%
private-kernel-inner 0.067s -2%

Copy link
Contributor

github-actions bot commented Jan 17, 2025

Compilation Memory Report

Program Peak Memory
keccak256 77.65M
workspace 123.88M
regression_4709 424.15M
ram_blowup_regression 1.46G
rollup-root 601.26M
rollup-merge 494.24M
rollup-block-root-single-tx 16.06G
rollup-block-root-empty 488.41M
rollup-block-root 16.07G
rollup-block-merge 601.26M
rollup-base-public 2.38G
rollup-base-private 1.14G
private-kernel-tail 207.34M
private-kernel-reset 584.47M
private-kernel-inner 294.71M

Copy link
Contributor

github-actions bot commented Jan 17, 2025

Execution Memory Report

Program Peak Memory
keccak256 74.71M
workspace 123.33M
regression_4709 316.02M
ram_blowup_regression 512.62M
rollup-root 498.31M
rollup-merge 473.05M
rollup-block-root 1.22G
rollup-block-merge 498.33M
rollup-base-public 734.17M
rollup-base-private 590.51M
private-kernel-tail 180.91M
private-kernel-reset 245.52M
private-kernel-inner 208.92M

@aakoshh aakoshh force-pushed the af/simplify-defunctionalize-return branch from 7ace374 to 4e3ea96 Compare January 17, 2025 13:43
@aakoshh aakoshh marked this pull request as ready for review January 17, 2025 13:43
@aakoshh aakoshh requested a review from a team January 17, 2025 13:44
Copy link
Contributor

Changes to Brillig bytecode sizes

Generated at commit: e4428361f7ddf0639c70cf9ca1d9ff34fa32d34f, compared to commit: bd4f90b054038e52af56f21be828efebd4c0d005

🧾 Summary (10% most significant diffs)

Program Brillig opcodes (+/-) %
higher_order_functions_inliner_zero -4 ✅ -0.46%
brillig_fns_as_values_inliner_min -2 ✅ -1.00%
brillig_fns_as_values_inliner_zero -2 ✅ -1.48%

Full diff report 👇
Program Brillig opcodes (+/-) %
hashmap_inliner_max 19,770 (-8) -0.04%
uhashmap_inliner_max 12,703 (-8) -0.06%
hashmap_inliner_min 12,336 (-12) -0.10%
uhashmap_inliner_min 9,734 (-12) -0.12%
hashmap_inliner_zero 8,081 (-12) -0.15%
sha256_regression_inliner_min 5,355 (-8) -0.15%
uhashmap_inliner_zero 7,479 (-12) -0.16%
sha256_regression_inliner_zero 4,861 (-8) -0.16%
sha256_var_padding_regression_inliner_min 3,300 (-6) -0.18%
sha256_var_padding_regression_inliner_zero 2,957 (-6) -0.20%
higher_order_functions_inliner_min 1,319 (-4) -0.30%
higher_order_functions_inliner_zero 867 (-4) -0.46%
brillig_fns_as_values_inliner_min 198 (-2) -1.00%
brillig_fns_as_values_inliner_zero 133 (-2) -1.48%

Copy link
Contributor

Changes to number of Brillig opcodes executed

Generated at commit: e4428361f7ddf0639c70cf9ca1d9ff34fa32d34f, compared to commit: bd4f90b054038e52af56f21be828efebd4c0d005

🧾 Summary (10% most significant diffs)

Program Brillig opcodes (+/-) %
higher_order_functions_inliner_zero -26 ✅ -1.39%
brillig_fns_as_values_inliner_min -6 ✅ -1.72%
brillig_fns_as_values_inliner_zero -6 ✅ -3.26%

Full diff report 👇
Program Brillig opcodes (+/-) %
sha256_var_padding_regression_inliner_min 271,083 (-24) -0.01%
sha256_var_padding_regression_inliner_zero 265,671 (-24) -0.01%
sha256_regression_inliner_min 161,295 (-28) -0.02%
sha256_regression_inliner_zero 155,415 (-28) -0.02%
uhashmap_inliner_max 137,636 (-60) -0.04%
uhashmap_inliner_min 230,214 (-108) -0.05%
uhashmap_inliner_zero 176,297 (-108) -0.06%
hashmap_inliner_min 113,917 (-108) -0.09%
hashmap_inliner_max 48,525 (-60) -0.12%
hashmap_inliner_zero 76,420 (-108) -0.14%
higher_order_functions_inliner_min 2,878 (-26) -0.90%
higher_order_functions_inliner_zero 1,840 (-26) -1.39%
brillig_fns_as_values_inliner_min 343 (-6) -1.72%
brillig_fns_as_values_inliner_zero 178 (-6) -3.26%

@TomAFrench TomAFrench merged commit 1b7dc2e into fix-defunctionalize-runtime Jan 17, 2025
99 checks passed
@TomAFrench TomAFrench deleted the af/simplify-defunctionalize-return branch January 17, 2025 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants