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

perf: remove unneeded bitshift in validated addresses insertion #1208

Merged
merged 15 commits into from
Jul 31, 2023

Conversation

MegaRedHand
Copy link
Contributor

@MegaRedHand MegaRedHand commented Jun 6, 2023

TITLE

Description

This PR changes the insert used in AddressSet::extend for a replace. This caused the vec to have a trailing false that was later truncated and that caused the insert to use a bitshift on the last element (as shown in flamegraphs).

Checklist

  • Linked to Github Issue
  • Unit tests added
  • Integration tests added.
  • This change requires new documentation.
    • Documentation has been added/updated.
    • CHANGELOG has been updated.

@github-actions
Copy link

github-actions bot commented Jun 6, 2023

Benchmark Results for unmodified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
base big_factorial 6.038 ± 0.136 5.772 6.221 1.02 ± 0.03
head big_factorial 5.901 ± 0.102 5.726 6.068 1.00
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 5.286 ± 0.073 5.196 5.414 1.06 ± 0.02
head big_fibonacci 4.993 ± 0.068 4.897 5.133 1.00
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 14.517 ± 0.281 13.898 14.813 1.05 ± 0.03
head blake2s_integration_benchmark 13.791 ± 0.190 13.595 14.108 1.00
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 5.325 ± 0.071 5.177 5.441 1.05 ± 0.02
head compare_arrays_200000 5.094 ± 0.086 4.962 5.210 1.00
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 3.562 ± 0.101 3.455 3.796 1.06 ± 0.03
head dict_integration_benchmark 3.361 ± 0.030 3.321 3.411 1.00
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 2.423 ± 0.049 2.365 2.514 1.08 ± 0.03
head field_arithmetic_get_square_benchmark 2.237 ± 0.052 2.177 2.352 1.00
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 14.391 ± 0.152 14.151 14.590 1.06 ± 0.02
head integration_builtins 13.609 ± 0.148 13.411 13.821 1.00
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 14.680 ± 0.173 14.345 14.879 1.06 ± 0.02
head keccak_integration_benchmark 13.834 ± 0.215 13.503 14.103 1.00
Command Mean [s] Min [s] Max [s] Relative
base linear_search 5.204 ± 0.049 5.153 5.299 1.03 ± 0.03
head linear_search 5.043 ± 0.128 4.860 5.301 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 3.782 ± 0.097 3.605 3.899 1.05 ± 0.03
head math_cmp_and_pow_integration_benchmark 3.593 ± 0.062 3.513 3.694 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 3.465 ± 0.062 3.345 3.564 1.07 ± 0.03
head math_integration_benchmark 3.251 ± 0.074 3.116 3.342 1.00
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 3.045 ± 0.054 2.950 3.137 1.06 ± 0.03
head memory_integration_benchmark 2.868 ± 0.059 2.785 2.985 1.00
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 3.293 ± 0.083 3.128 3.435 1.07 ± 0.03
head operations_with_data_structures_benchmarks 3.075 ± 0.052 2.971 3.134 1.00
Command Mean [s] Min [s] Max [s] Relative
base pedersen 1.215 ± 0.031 1.177 1.265 1.00 ± 0.04
head pedersen 1.210 ± 0.029 1.161 1.249 1.00
Command Mean [s] Min [s] Max [s] Relative
base poseidon_integration_benchmark 2.152 ± 0.054 2.031 2.207 1.02 ± 0.03
head poseidon_integration_benchmark 2.113 ± 0.036 2.074 2.170 1.00
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 4.168 ± 0.052 4.085 4.246 1.04 ± 0.03
head secp_integration_benchmark 4.012 ± 0.086 3.935 4.186 1.00
Command Mean [s] Min [s] Max [s] Relative
base set_integration_benchmark 2.428 ± 0.042 2.381 2.519 1.03 ± 0.03
head set_integration_benchmark 2.369 ± 0.047 2.288 2.419 1.00
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 9.178 ± 0.124 8.955 9.369 1.06 ± 0.02
head uint256_integration_benchmark 8.644 ± 0.145 8.457 8.877 1.00

@codecov
Copy link

codecov bot commented Jun 6, 2023

Codecov Report

Merging #1208 (a669b15) into main (1642e70) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #1208   +/-   ##
=======================================
  Coverage   97.49%   97.49%           
=======================================
  Files          93       93           
  Lines       37853    37854    +1     
=======================================
+ Hits        36903    36904    +1     
  Misses        950      950           
Files Changed Coverage Δ
vm/src/vm/vm_memory/memory.rs 98.74% <100.00%> (+<0.01%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@MegaRedHand MegaRedHand changed the title perf: remove unneeded? shift in validated addresses insertion perf: remove unneeded bitshift in validated addresses insertion Jun 6, 2023
@MegaRedHand MegaRedHand marked this pull request as ready for review June 6, 2023 19:12
The +1 in resize is used to avoid having to allocate in the case the next push falls outside capacity.
Instead, we use a replace in the place of the insert.
@MegaRedHand MegaRedHand marked this pull request as draft June 12, 2023 13:27
@MegaRedHand MegaRedHand marked this pull request as ready for review July 19, 2023 21:11
@Oppen Oppen added this pull request to the merge queue Jul 31, 2023
Merged via the queue into main with commit e7a0022 Jul 31, 2023
38 checks passed
@Oppen Oppen deleted the optimize-AddressSet_extend branch July 31, 2023 23:05
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.

None yet

4 participants