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: use VirtualMachine::load_data at initialization #1441

Merged
merged 2 commits into from
Jan 26, 2024

Conversation

Oppen
Copy link
Contributor

@Oppen Oppen commented Sep 11, 2023

The CairoRunner::initialize_state was using SegmentManager::load_data to load
the code rather than VirtualMachine::load_data. The latter contains an optimization
for the instruction cache, where it gets resized when loading the segment 0,
saving us from many reallocations during the main loop.
Running transactions 68000-68500 with Pathfinder shows a 9% speed improvement.

Checklist

  • This change requires new documentation.
    • CHANGELOG has been updated.

@Oppen Oppen force-pushed the perf/load_data_sets_cache_size branch from 00baaa8 to 9219369 Compare September 11, 2023 14:02
@codecov
Copy link

codecov bot commented Sep 11, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (0a39534) 97.12% compared to head (768bdc3) 97.12%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1441      +/-   ##
==========================================
- Coverage   97.12%   97.12%   -0.01%     
==========================================
  Files          91       91              
  Lines       37246    37245       -1     
==========================================
- Hits        36176    36175       -1     
  Misses       1070     1070              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions
Copy link

github-actions bot commented Sep 11, 2023

Benchmark Results for unmodified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
base big_factorial 2.258 ± 0.013 2.235 2.285 1.00
head big_factorial 2.267 ± 0.011 2.254 2.291 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 2.249 ± 0.013 2.222 2.266 1.00
head big_fibonacci 2.250 ± 0.018 2.230 2.293 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 8.230 ± 0.066 8.163 8.335 1.00 ± 0.01
head blake2s_integration_benchmark 8.195 ± 0.045 8.153 8.288 1.00
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 2.307 ± 0.015 2.283 2.326 1.00 ± 0.01
head compare_arrays_200000 2.306 ± 0.020 2.286 2.358 1.00
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 1.455 ± 0.005 1.449 1.467 1.01 ± 0.01
head dict_integration_benchmark 1.444 ± 0.006 1.438 1.460 1.00
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.294 ± 0.010 1.285 1.319 1.00 ± 0.01
head field_arithmetic_get_square_benchmark 1.292 ± 0.007 1.285 1.306 1.00
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 8.269 ± 0.066 8.186 8.348 1.00
head integration_builtins 8.298 ± 0.177 8.196 8.786 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 8.542 ± 0.055 8.473 8.613 1.00
head keccak_integration_benchmark 8.546 ± 0.085 8.438 8.725 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base linear_search 2.326 ± 0.007 2.313 2.336 1.00
head linear_search 2.336 ± 0.022 2.313 2.389 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 1.583 ± 0.010 1.567 1.607 1.00 ± 0.01
head math_cmp_and_pow_integration_benchmark 1.580 ± 0.010 1.572 1.606 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 1.432 ± 0.007 1.424 1.442 1.00
head math_integration_benchmark 1.442 ± 0.004 1.436 1.447 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 1.253 ± 0.004 1.247 1.258 1.00
head memory_integration_benchmark 1.260 ± 0.005 1.255 1.268 1.01 ± 0.00
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 1.617 ± 0.008 1.605 1.634 1.00 ± 0.01
head operations_with_data_structures_benchmarks 1.610 ± 0.006 1.603 1.620 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 604.2 ± 0.9 602.1 604.9 1.00 ± 0.00
head pedersen 603.9 ± 0.8 603.0 605.4 1.00
Command Mean [s] Min [s] Max [s] Relative
base poseidon_integration_benchmark 1.067 ± 0.003 1.062 1.071 1.00
head poseidon_integration_benchmark 1.067 ± 0.007 1.057 1.084 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 1.934 ± 0.010 1.922 1.957 1.00
head secp_integration_benchmark 1.938 ± 0.007 1.930 1.950 1.00 ± 0.01
Command Mean [ms] Min [ms] Max [ms] Relative
base set_integration_benchmark 753.2 ± 1.5 751.7 755.7 1.00
head set_integration_benchmark 753.5 ± 2.1 750.6 758.6 1.00 ± 0.00
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 4.527 ± 0.017 4.505 4.553 1.00
head uint256_integration_benchmark 4.548 ± 0.032 4.511 4.596 1.00 ± 0.01

fmoletta
fmoletta previously approved these changes Oct 9, 2023
@pefontana pefontana enabled auto-merge January 26, 2024 19:35
@pefontana pefontana added this pull request to the merge queue Jan 26, 2024
Merged via the queue into main with commit 0ea638f Jan 26, 2024
50 checks passed
@pefontana pefontana deleted the perf/load_data_sets_cache_size branch January 26, 2024 20:31
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.

3 participants