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: share constants between Program instances #1442

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Oppen
Copy link
Member

@Oppen Oppen commented Sep 11, 2023

This reduces Program cloning for building the CairoRunner by 86%
according to our Criterion benchmarks.
Running transactions 68000-68500 with Pathfinder shows a 7% improvement.

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.

This reduces `Program` cloning for building the `CairoRunner` by 86%
according to our Criterion benchmarks.
This is a significant cost for running many short-lived programs such
as most Starknet transactions.
No negative impact in runtime was observed.
@codecov
Copy link

codecov bot commented Sep 11, 2023

Codecov Report

Merging #1442 (e7cad97) into main (bd496ea) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1442      +/-   ##
==========================================
- Coverage   96.98%   96.98%   -0.01%     
==========================================
  Files          93       93              
  Lines       38637    38636       -1     
==========================================
- Hits        37474    37473       -1     
  Misses       1163     1163              
Files Changed Coverage Δ
vm/src/serde/deserialize_program.rs 97.32% <100.00%> (ø)
vm/src/types/program.rs 99.42% <100.00%> (-0.01%) ⬇️
vm/src/utils.rs 99.49% <100.00%> (ø)
vm/src/vm/runners/cairo_runner.rs 98.04% <100.00%> (ø)

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

@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 3.612 ± 0.018 3.589 3.644 1.01 ± 0.01
head big_factorial 3.583 ± 0.011 3.565 3.600 1.00
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 3.111 ± 0.020 3.090 3.149 1.00
head big_fibonacci 3.167 ± 0.172 3.097 3.657 1.02 ± 0.06
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 8.903 ± 0.113 8.810 9.189 1.01 ± 0.01
head blake2s_integration_benchmark 8.780 ± 0.030 8.752 8.860 1.00
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 3.136 ± 0.012 3.118 3.153 1.00
head compare_arrays_200000 3.205 ± 0.086 3.128 3.415 1.02 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 2.187 ± 0.012 2.168 2.206 1.02 ± 0.01
head dict_integration_benchmark 2.140 ± 0.007 2.129 2.151 1.00
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.661 ± 0.011 1.650 1.681 1.00 ± 0.01
head field_arithmetic_get_square_benchmark 1.654 ± 0.006 1.643 1.664 1.00
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 8.860 ± 0.083 8.780 9.038 1.01 ± 0.01
head integration_builtins 8.794 ± 0.051 8.740 8.917 1.00
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 8.994 ± 0.059 8.929 9.101 1.00
head keccak_integration_benchmark 9.021 ± 0.138 8.897 9.366 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base linear_search 3.195 ± 0.009 3.183 3.217 1.00
head linear_search 3.274 ± 0.100 3.187 3.459 1.02 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 2.298 ± 0.005 2.288 2.306 1.00
head math_cmp_and_pow_integration_benchmark 2.315 ± 0.029 2.297 2.397 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 2.094 ± 0.009 2.079 2.110 1.00 ± 0.01
head math_integration_benchmark 2.091 ± 0.009 2.082 2.107 1.00
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 1.833 ± 0.008 1.821 1.844 1.00
head memory_integration_benchmark 1.851 ± 0.030 1.820 1.930 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 2.072 ± 0.049 2.044 2.207 1.01 ± 0.03
head operations_with_data_structures_benchmarks 2.060 ± 0.017 2.040 2.096 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 774.5 ± 0.9 773.2 776.6 1.00 ± 0.00
head pedersen 772.9 ± 1.9 770.2 775.8 1.00
Command Mean [s] Min [s] Max [s] Relative
base poseidon_integration_benchmark 1.501 ± 0.003 1.495 1.504 1.00
head poseidon_integration_benchmark 1.514 ± 0.011 1.502 1.540 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 2.547 ± 0.011 2.531 2.571 1.00
head secp_integration_benchmark 2.552 ± 0.020 2.536 2.606 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base set_integration_benchmark 1.331 ± 0.005 1.325 1.343 1.01 ± 0.01
head set_integration_benchmark 1.321 ± 0.009 1.310 1.342 1.00
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 5.894 ± 0.037 5.841 5.947 1.00 ± 0.01
head uint256_integration_benchmark 5.866 ± 0.025 5.836 5.914 1.00

@Oppen
Copy link
Member Author

Oppen commented Sep 14, 2023

Interestingly this shows a slowdown. I guess I'll have to run the benchmarks again in the server and my workstation just in case. Converting to draft in the meantime.

@Oppen Oppen marked this pull request as draft September 14, 2023 18:34
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.

2 participants