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

[Cairo 1] Fix handling of return values wrapped in `PanicResult` #1763

Closed fmoletta closed 1 month ago

fmoletta commented 1 month ago

Now properly accounts for PanicResult enum padding when fetching return values. Removes workaround used to handle this bug in the specific case of array/span returns

github-actions[bot] commented 1 month 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 ± σ):     27.232 s ±  0.006 s    [User: 26.382 s, System: 0.848 s]
  Range (min … max):   27.227 s … 27.236 s    2 runs

Benchmark 2: hyper_threading_pr threads: 1
  Time (mean ± σ):     27.175 s ±  0.048 s    [User: 26.365 s, System: 0.810 s]
  Range (min … max):   27.141 s … 27.210 s    2 runs

Summary
  'hyper_threading_pr threads: 1' ran
    1.00 ± 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 ± σ):     14.764 s ±  0.038 s    [User: 26.864 s, System: 0.824 s]
  Range (min … max):   14.737 s … 14.790 s    2 runs

Benchmark 2: hyper_threading_pr threads: 2
  Time (mean ± σ):     14.763 s ±  0.000 s    [User: 26.836 s, System: 0.832 s]
  Range (min … max):   14.763 s … 14.764 s    2 runs

Summary
  'hyper_threading_pr threads: 2' ran
    1.00 ± 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 ± σ):     11.219 s ±  0.125 s    [User: 38.926 s, System: 0.954 s]
  Range (min … max):   11.131 s … 11.308 s    2 runs

Benchmark 2: hyper_threading_pr threads: 4
  Time (mean ± σ):     11.022 s ±  0.247 s    [User: 39.056 s, System: 0.980 s]
  Range (min … max):   10.848 s … 11.196 s    2 runs

Summary
  'hyper_threading_pr threads: 4' ran
    1.02 ± 0.03 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.980 s ±  0.264 s    [User: 39.090 s, System: 1.022 s]
  Range (min … max):   10.794 s … 11.167 s    2 runs

Benchmark 2: hyper_threading_pr threads: 6
  Time (mean ± σ):     11.028 s ±  0.239 s    [User: 39.252 s, System: 1.003 s]
  Range (min … max):   10.859 s … 11.196 s    2 runs

Summary
  'hyper_threading_main threads: 6' ran
    1.00 ± 0.03 times faster than 'hyper_threading_pr 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.683 s ±  0.108 s    [User: 39.615 s, System: 1.106 s]
  Range (min … max):   10.606 s … 10.759 s    2 runs

Benchmark 2: hyper_threading_pr threads: 8
  Time (mean ± σ):     10.772 s ±  0.099 s    [User: 39.350 s, System: 1.057 s]
  Range (min … max):   10.702 s … 10.841 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.930 s ±  0.020 s    [User: 39.686 s, System: 1.115 s]
  Range (min … max):   10.915 s … 10.944 s    2 runs

Benchmark 2: hyper_threading_pr threads: 16
  Time (mean ± σ):     10.498 s ±  0.016 s    [User: 39.933 s, System: 1.112 s]
  Range (min … max):   10.487 s … 10.510 s    2 runs

Summary
  'hyper_threading_pr threads: 16' ran
    1.04 ± 0.00 times faster than 'hyper_threading_main threads: 16'
codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 97.29730% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 94.79%. Comparing base (f87be4d) to head (a9e6a16).

Files Patch % Lines
cairo1-run/src/cairo_run.rs 97.29% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1763 +/- ## ======================================= Coverage 94.79% 94.79% ======================================= Files 101 101 Lines 38723 38743 +20 ======================================= + Hits 36709 36728 +19 - Misses 2014 2015 +1 ```

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

github-actions[bot] commented 1 month ago

Benchmark Results for unmodified programs :rocket:

Command Mean [s] Min [s] Max [s] Relative
base big_factorial 2.040 ± 0.011 2.020 2.063 1.00
head big_factorial 2.044 ± 0.016 2.026 2.072 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 2.008 ± 0.047 1.970 2.131 1.01 ± 0.03
head big_fibonacci 1.993 ± 0.023 1.971 2.049 1.00
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 7.575 ± 0.176 7.452 8.064 1.00
head blake2s_integration_benchmark 7.672 ± 0.330 7.490 8.536 1.01 ± 0.05
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 2.132 ± 0.026 2.100 2.194 1.01 ± 0.02
head compare_arrays_200000 2.119 ± 0.021 2.094 2.155 1.00
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 1.419 ± 0.013 1.408 1.445 1.00
head dict_integration_benchmark 1.422 ± 0.009 1.412 1.439 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.308 ± 0.052 1.274 1.424 1.02 ± 0.04
head field_arithmetic_get_square_benchmark 1.287 ± 0.010 1.273 1.305 1.00
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 7.613 ± 0.116 7.438 7.863 1.00 ± 0.02
head integration_builtins 7.595 ± 0.099 7.487 7.836 1.00
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 7.836 ± 0.118 7.728 8.159 1.01 ± 0.03
head keccak_integration_benchmark 7.790 ± 0.170 7.676 8.252 1.00
Command Mean [s] Min [s] Max [s] Relative
base linear_search 2.085 ± 0.021 2.067 2.126 1.00
head linear_search 2.086 ± 0.025 2.066 2.145 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 1.692 ± 0.007 1.679 1.702 1.00
head math_cmp_and_pow_integration_benchmark 1.704 ± 0.031 1.686 1.790 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 1.603 ± 0.009 1.590 1.620 1.00
head math_integration_benchmark 1.610 ± 0.014 1.596 1.647 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 1.210 ± 0.025 1.191 1.264 1.00
head memory_integration_benchmark 1.210 ± 0.018 1.195 1.248 1.00 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 1.806 ± 0.009 1.797 1.828 1.00
head operations_with_data_structures_benchmarks 1.812 ± 0.014 1.797 1.842 1.00 ± 0.01
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 513.1 ± 2.6 508.4 516.6 1.00
head pedersen 516.3 ± 5.4 511.5 529.2 1.01 ± 0.01
Command Mean [ms] Min [ms] Max [ms] Relative
base poseidon_integration_benchmark 964.3 ± 4.0 957.9 969.9 1.00
head poseidon_integration_benchmark 969.1 ± 8.5 956.1 986.1 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 1.891 ± 0.056 1.858 2.033 1.01 ± 0.03
head secp_integration_benchmark 1.869 ± 0.020 1.853 1.911 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base set_integration_benchmark 667.3 ± 2.4 664.0 672.4 1.00
head set_integration_benchmark 671.8 ± 9.1 664.0 691.7 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 4.244 ± 0.035 4.188 4.292 1.00 ± 0.02
head uint256_integration_benchmark 4.238 ± 0.068 4.183 4.403 1.00