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: cache decoded instructions #944

Merged
merged 1 commit into from
May 5, 2023
Merged

perf: cache decoded instructions #944

merged 1 commit into from
May 5, 2023

Conversation

Oppen
Copy link
Member

@Oppen Oppen commented Apr 3, 2023

Checklist

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

@github-actions
Copy link

github-actions bot commented May 4, 2023

Benchmark Results for unmodified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 20.001 ± 0.254 19.783 20.656 1.16 ± 0.02
head blake2s_integration_benchmark 17.288 ± 0.085 17.186 17.470 1.00
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 5.997 ± 0.084 5.930 6.128 1.12 ± 0.02
head compare_arrays_200000 5.377 ± 0.023 5.354 5.430 1.00
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 3.758 ± 0.025 3.732 3.815 1.07 ± 0.02
head dict_integration_benchmark 3.526 ± 0.068 3.474 3.632 1.00
Command Mean [s] Min [s] Max [s] Relative
base factorial_multirun 6.326 ± 0.015 6.299 6.346 1.10 ± 0.01
head factorial_multirun 5.771 ± 0.027 5.739 5.808 1.00
Command Mean [s] Min [s] Max [s] Relative
base fibonacci_1000_multirun 5.614 ± 0.073 5.556 5.774 1.13 ± 0.02
head fibonacci_1000_multirun 4.975 ± 0.015 4.959 5.013 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base field_arithmetic_get_square_benchmark 244.7 ± 1.2 242.8 246.8 1.07 ± 0.02
head field_arithmetic_get_square_benchmark 228.5 ± 3.6 224.9 237.7 1.00
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 19.156 ± 1.456 18.502 23.224 1.21 ± 0.09
head integration_builtins 15.860 ± 0.099 15.770 16.095 1.00
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 20.169 ± 0.546 19.820 21.699 1.16 ± 0.03
head keccak_integration_benchmark 17.404 ± 0.121 17.294 17.646 1.00
Command Mean [s] Min [s] Max [s] Relative
base linear_search 5.994 ± 0.047 5.947 6.098 1.11 ± 0.01
head linear_search 5.401 ± 0.033 5.365 5.470 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 4.033 ± 0.030 4.010 4.115 1.07 ± 0.02
head math_cmp_and_pow_integration_benchmark 3.771 ± 0.049 3.736 3.890 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 3.822 ± 0.017 3.802 3.852 1.09 ± 0.01
head math_integration_benchmark 3.498 ± 0.011 3.481 3.511 1.00
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 3.329 ± 0.008 3.319 3.344 1.09 ± 0.01
head memory_integration_benchmark 3.053 ± 0.025 3.029 3.111 1.00
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 3.751 ± 0.009 3.737 3.762 1.08 ± 0.00
head operations_with_data_structures_benchmarks 3.479 ± 0.012 3.462 3.500 1.00
Command Mean [s] Min [s] Max [s] Relative
base pedersen 1.215 ± 0.006 1.204 1.222 1.07 ± 0.01
head pedersen 1.132 ± 0.002 1.128 1.135 1.00
Command Mean [s] Min [s] Max [s] Relative
base poseidon_integration_benchmark 2.009 ± 0.011 1.995 2.036 1.04 ± 0.01
head poseidon_integration_benchmark 1.930 ± 0.006 1.920 1.938 1.00
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 4.635 ± 0.034 4.607 4.724 1.07 ± 0.01
head secp_integration_benchmark 4.325 ± 0.009 4.314 4.340 1.00
Command Mean [s] Min [s] Max [s] Relative
base set_integration_benchmark 2.369 ± 0.004 2.359 2.375 1.02 ± 0.01
head set_integration_benchmark 2.332 ± 0.014 2.320 2.358 1.00
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 11.985 ± 0.074 11.872 12.097 1.12 ± 0.01
head uint256_integration_benchmark 10.707 ± 0.021 10.680 10.749 1.00

@codecov
Copy link

codecov bot commented May 4, 2023

Codecov Report

Merging #944 (e0a3b63) into main (c17aa23) will increase coverage by 0.00%.
The diff coverage is 93.54%.

❗ Current head e0a3b63 differs from pull request most recent head f12f2d2. Consider uploading reports for the commit f12f2d2 to get more accurate results

@@           Coverage Diff           @@
##             main     #944   +/-   ##
=======================================
  Coverage   98.15%   98.15%           
=======================================
  Files          85       85           
  Lines       34534    34549   +15     
=======================================
+ Hits        33897    33912   +15     
  Misses        637      637           
Impacted Files Coverage Δ
src/types/instruction.rs 95.74% <75.00%> (ø)
src/vm/vm_core.rs 97.88% <100.00%> (+0.01%) ⬆️

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

Decoding instructions (including fetching from memory, converting them
to `u64` and later on parsing them) takes up a significant portion of
time spent executing the main loop. Caching them as they get decoded
alleviates it, reducing runtime in proof mode benchmarks up to 9%.
@Oppen Oppen changed the title Inst cache perf: cache decoded instructions May 4, 2023
@Oppen Oppen marked this pull request as ready for review May 4, 2023 16:43
Copy link
Member

@pefontana pefontana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one!

@pefontana
Copy link
Member

pefontana commented May 5, 2023

I don't get why codecov fails in the #[derive(Copy, Clone lines

@Oppen
Copy link
Member Author

Oppen commented May 5, 2023

I don't get why codecov fails in the #[derive(Copy, Clone lines

Yes, it's annoying. It boils down to the code generated apparently not being covered. Maybe I sprinkled it in a few more places than needed.

@Oppen Oppen added this pull request to the merge queue May 5, 2023
Merged via the queue into main with commit c035797 May 5, 2023
30 of 31 checks passed
@Oppen Oppen deleted the inst_cache branch May 5, 2023 22:42
kariy pushed a commit to dojoengine/cairo-rs that referenced this pull request Jun 23, 2023
Decoding instructions (including fetching from memory, converting them
to `u64` and later on parsing them) takes up a significant portion of
time spent executing the main loop. Caching them as they get decoded
alleviates it, reducing runtime in proof mode benchmarks up to 9%.
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

3 participants