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: Deduplicate to common ancestor #6518

Closed
wants to merge 3 commits into from
Closed

Conversation

jfecher
Copy link
Contributor

@jfecher jfecher commented Nov 14, 2024

Description

Problem*

This implements the alternate version mentioned in #6517 where we only hoist if there are multiple ValueIds. This means we do not hoist the loop example given there since there is no usage of x + 1 before the loop.

Summary*

Improves the instruction deduplication optimization by moving the instruction to a common ancestor of both blocks if neither dominate the other.

Additional Context

Testing this to see how much of an improvement it gives. The hoisting doesn't occur recursively (so multiple instructions depending on eachother will only have the first hoisted) and relies on another constant folding pass to change the earlier instructions to the hoisted version so performance can still be improved.

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

Changes to Brillig bytecode sizes

Generated at commit: d756449fa167486e5f7f0989f39fa64ce6e7ae6c, compared to commit: 852c87ae9ecdd441ee4c2ab3e78e86b2da07d8a4

🧾 Summary (10% most significant diffs)

Program Brillig opcodes (+/-) %
binary_operator_overloading -9 ✅ -2.28%
conditional_regression_661 -3 ✅ -2.31%
break_and_continue -5 ✅ -8.20%
regression_3607 -5 ✅ -10.20%

Full diff report 👇
Program Brillig opcodes (+/-) %
slice_dynamic_index 2,744 (+8) +0.29%
hashmap 26,648 (-8) -0.03%
uhashmap 16,302 (-8) -0.05%
eddsa 10,876 (-18) -0.17%
brillig_slices 531 (-1) -0.19%
poseidon_bn254_hash_width_3 5,680 (-12) -0.21%
poseidon_bn254_hash 5,680 (-12) -0.21%
slices 2,258 (-5) -0.22%
regression_5252 4,867 (-12) -0.25%
poseidonsponge_x5_254 4,490 (-12) -0.27%
sha2_byte 3,373 (-15) -0.44%
tuple_inputs 375 (-2) -0.53%
regression 724 (-5) -0.69%
nested_array_in_slice 1,192 (-10) -0.83%
aes128_encrypt 522 (-5) -0.95%
references 286 (-4) -1.38%
nested_array_dynamic 2,145 (-36) -1.65%
bigint 2,045 (-45) -2.15%
binary_operator_overloading 386 (-9) -2.28%
conditional_regression_661 127 (-3) -2.31%
break_and_continue 56 (-5) -8.20%
regression_3607 44 (-5) -10.20%

Copy link
Contributor

Changes to number of Brillig opcodes executed

Generated at commit: d756449fa167486e5f7f0989f39fa64ce6e7ae6c, compared to commit: 852c87ae9ecdd441ee4c2ab3e78e86b2da07d8a4

🧾 Summary (10% most significant diffs)

Program Brillig opcodes (+/-) %
break_and_continue +3 ❌ +2.70%
slice_dynamic_index +53 ❌ +1.22%
references -20 ✅ -4.87%

Full diff report 👇
Program Brillig opcodes (+/-) %
break_and_continue 114 (+3) +2.70%
slice_dynamic_index 4,408 (+53) +1.22%
conditional_1 5,896 (+36) +0.61%
regression_5252 955,406 (+4,200) +0.44%
poseidonsponge_x5_254 191,757 (+840) +0.44%
poseidon_bn254_hash 170,131 (+579) +0.34%
poseidon_bn254_hash_width_3 170,131 (+579) +0.34%
eddsa 739,151 (+1,872) +0.25%
brillig_slices 712 (+1) +0.14%
hashmap 58,469 (+48) +0.08%
slices 3,832 (+2) +0.05%
nested_array_dynamic 3,117 (+1) +0.03%
uhashmap 153,666 (+48) +0.03%
tuple_inputs 636 (-1) -0.16%
references 391 (-20) -4.87%

@jfecher jfecher closed this Nov 14, 2024
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.

1 participant