lambdaclass / cairo-vm

cairo-vm is a Rust implementation of the Cairo VM. Cairo (CPU Algebraic Intermediate Representation) is a programming language for writing provable programs, where one party can prove to another that a certain computation was executed correctly without the need for this party to re-execute the same program.
https://lambdaclass.github.io/cairo-vm
Apache License 2.0
485 stars 132 forks source link

[Cairo1] Fix `GasBuiltin` handling #1789

Closed fmoletta closed 3 weeks ago

fmoletta commented 3 weeks ago

Fixes bug reported by #1788 Changes:

Testing:

github-actions[bot] commented 3 weeks ago
**Hyper Thereading Benchmark results**

hyperfine -r 2 -n "hyper_threading_main threads: 1" 'RAYON_NUM_THREADS=1 ./hyper_threading_main' -n "hyper_threading_pr threads: 1" 'RAYON_NUM_THREADS=1 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 1
  Time (mean ± σ):     26.869 s ±  0.037 s    [User: 26.063 s, System: 0.804 s]
  Range (min … max):   26.843 s … 26.895 s    2 runs

Benchmark 2: hyper_threading_pr threads: 1
  Time (mean ± σ):     26.567 s ±  0.039 s    [User: 25.789 s, System: 0.776 s]
  Range (min … max):   26.540 s … 26.594 s    2 runs

Summary
  'hyper_threading_pr threads: 1' ran
    1.01 ± 0.00 times faster than 'hyper_threading_main threads: 1'

hyperfine -r 2 -n "hyper_threading_main threads: 2" 'RAYON_NUM_THREADS=2 ./hyper_threading_main' -n "hyper_threading_pr threads: 2" 'RAYON_NUM_THREADS=2 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 2
  Time (mean ± σ):     15.145 s ±  0.004 s    [User: 26.714 s, System: 0.768 s]
  Range (min … max):   15.142 s … 15.147 s    2 runs

Benchmark 2: hyper_threading_pr threads: 2
  Time (mean ± σ):     14.964 s ±  0.010 s    [User: 26.264 s, System: 0.855 s]
  Range (min … max):   14.957 s … 14.972 s    2 runs

Summary
  'hyper_threading_pr threads: 2' ran
    1.01 ± 0.00 times faster than 'hyper_threading_main threads: 2'

hyperfine -r 2 -n "hyper_threading_main threads: 4" 'RAYON_NUM_THREADS=4 ./hyper_threading_main' -n "hyper_threading_pr threads: 4" 'RAYON_NUM_THREADS=4 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 4
  Time (mean ± σ):     10.960 s ±  0.041 s    [User: 37.944 s, System: 0.957 s]
  Range (min … max):   10.931 s … 10.989 s    2 runs

Benchmark 2: hyper_threading_pr threads: 4
  Time (mean ± σ):     10.884 s ±  0.003 s    [User: 37.838 s, System: 0.924 s]
  Range (min … max):   10.882 s … 10.887 s    2 runs

Summary
  'hyper_threading_pr threads: 4' ran
    1.01 ± 0.00 times faster than 'hyper_threading_main threads: 4'

hyperfine -r 2 -n "hyper_threading_main threads: 6" 'RAYON_NUM_THREADS=6 ./hyper_threading_main' -n "hyper_threading_pr threads: 6" 'RAYON_NUM_THREADS=6 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 6
  Time (mean ± σ):     10.735 s ±  0.220 s    [User: 37.888 s, System: 1.036 s]
  Range (min … max):   10.579 s … 10.890 s    2 runs

Benchmark 2: hyper_threading_pr threads: 6
  Time (mean ± σ):     10.404 s ±  0.072 s    [User: 38.210 s, System: 0.992 s]
  Range (min … max):   10.353 s … 10.455 s    2 runs

Summary
  'hyper_threading_pr threads: 6' ran
    1.03 ± 0.02 times faster than 'hyper_threading_main threads: 6'

hyperfine -r 2 -n "hyper_threading_main threads: 8" 'RAYON_NUM_THREADS=8 ./hyper_threading_main' -n "hyper_threading_pr threads: 8" 'RAYON_NUM_THREADS=8 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 8
  Time (mean ± σ):     10.307 s ±  0.033 s    [User: 38.431 s, System: 1.012 s]
  Range (min … max):   10.284 s … 10.330 s    2 runs

Benchmark 2: hyper_threading_pr threads: 8
  Time (mean ± σ):     10.410 s ±  0.075 s    [User: 38.178 s, System: 0.928 s]
  Range (min … max):   10.356 s … 10.463 s    2 runs

Summary
  'hyper_threading_main threads: 8' ran
    1.01 ± 0.01 times faster than 'hyper_threading_pr threads: 8'

hyperfine -r 2 -n "hyper_threading_main threads: 16" 'RAYON_NUM_THREADS=16 ./hyper_threading_main' -n "hyper_threading_pr threads: 16" 'RAYON_NUM_THREADS=16 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 16
  Time (mean ± σ):     10.242 s ±  0.097 s    [User: 38.894 s, System: 0.939 s]
  Range (min … max):   10.174 s … 10.311 s    2 runs

Benchmark 2: hyper_threading_pr threads: 16
  Time (mean ± σ):     10.534 s ±  0.110 s    [User: 38.548 s, System: 1.109 s]
  Range (min … max):   10.457 s … 10.612 s    2 runs

Summary
  'hyper_threading_main threads: 16' ran
    1.03 ± 0.01 times faster than 'hyper_threading_pr threads: 16'
codecov[bot] commented 3 weeks ago

Codecov Report

Attention: Patch coverage is 96.96970% with 1 line in your changes missing coverage. Please review.

Project coverage is 94.79%. Comparing base (3f9428e) to head (c748f1d).

Files Patch % Lines
cairo1-run/src/cairo_run.rs 96.96% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1789 +/- ## ======================================= Coverage 94.78% 94.79% ======================================= Files 102 102 Lines 40122 40141 +19 ======================================= + Hits 38031 38050 +19 Misses 2091 2091 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

github-actions[bot] commented 3 weeks ago

Benchmark Results for unmodified programs :rocket:

Command Mean [s] Min [s] Max [s] Relative
base big_factorial 2.067 ± 0.015 2.046 2.095 1.01 ± 0.01
head big_factorial 2.056 ± 0.025 2.033 2.113 1.00
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 2.008 ± 0.010 1.997 2.023 1.00
head big_fibonacci 2.013 ± 0.023 1.989 2.067 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 7.619 ± 0.061 7.497 7.697 1.00
head blake2s_integration_benchmark 7.656 ± 0.104 7.561 7.926 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 2.157 ± 0.044 2.125 2.275 1.01 ± 0.02
head compare_arrays_200000 2.130 ± 0.013 2.109 2.153 1.00
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 1.411 ± 0.011 1.399 1.434 1.00
head dict_integration_benchmark 1.412 ± 0.006 1.403 1.422 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.215 ± 0.018 1.199 1.253 1.00 ± 0.02
head field_arithmetic_get_square_benchmark 1.215 ± 0.006 1.205 1.224 1.00
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 7.690 ± 0.046 7.608 7.765 1.00
head integration_builtins 7.793 ± 0.459 7.574 9.083 1.01 ± 0.06
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 7.978 ± 0.179 7.819 8.457 1.01 ± 0.03
head keccak_integration_benchmark 7.890 ± 0.094 7.777 8.095 1.00
Command Mean [s] Min [s] Max [s] Relative
base linear_search 2.114 ± 0.047 2.076 2.228 1.01 ± 0.02
head linear_search 2.099 ± 0.015 2.077 2.120 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 1.470 ± 0.018 1.455 1.510 1.00
head math_cmp_and_pow_integration_benchmark 1.474 ± 0.029 1.454 1.548 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 1.449 ± 0.019 1.435 1.500 1.00
head math_integration_benchmark 1.454 ± 0.012 1.440 1.483 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 1.192 ± 0.008 1.178 1.203 1.00
head memory_integration_benchmark 1.202 ± 0.007 1.192 1.211 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 1.542 ± 0.026 1.523 1.594 1.01 ± 0.02
head operations_with_data_structures_benchmarks 1.533 ± 0.007 1.523 1.540 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 513.1 ± 1.2 511.1 515.1 1.00
head pedersen 514.6 ± 5.3 510.6 527.2 1.00 ± 0.01
Command Mean [ms] Min [ms] Max [ms] Relative
base poseidon_integration_benchmark 745.0 ± 3.4 739.9 751.1 1.00 ± 0.01
head poseidon_integration_benchmark 744.3 ± 6.9 735.9 756.3 1.00
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 1.814 ± 0.026 1.791 1.862 1.00 ± 0.02
head secp_integration_benchmark 1.813 ± 0.010 1.802 1.836 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base set_integration_benchmark 663.5 ± 2.0 661.4 666.9 1.00
head set_integration_benchmark 669.6 ± 15.6 662.2 713.6 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 4.230 ± 0.046 4.196 4.349 1.00
head uint256_integration_benchmark 4.279 ± 0.167 4.186 4.748 1.01 ± 0.04