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
509 stars 142 forks source link

Partially Revert `Optimize trace relocation #906` #1492

Closed fmoletta closed 9 months ago

fmoletta commented 10 months ago

When running the starknet os, the pc can take values outside of the program segment, which conflicts with our trace optimization, that takes advantage of the trace pc always being on segment 0. Partially reverts changes made by #906

github-actions[bot] commented 10 months ago

Benchmark Results for unmodified programs :rocket:

Command Mean [s] Min [s] Max [s] Relative
base big_factorial 2.567 ± 0.019 2.547 2.608 1.00
head big_factorial 2.624 ± 0.013 2.603 2.645 1.02 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 2.161 ± 0.012 2.146 2.183 1.00
head big_fibonacci 2.225 ± 0.015 2.200 2.256 1.03 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 6.014 ± 0.029 5.979 6.078 1.00
head blake2s_integration_benchmark 6.196 ± 0.039 6.129 6.254 1.03 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 2.254 ± 0.011 2.236 2.267 1.00
head compare_arrays_200000 2.346 ± 0.015 2.325 2.379 1.04 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 1.572 ± 0.009 1.563 1.591 1.00
head dict_integration_benchmark 1.614 ± 0.009 1.602 1.632 1.03 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.049 ± 0.007 1.041 1.063 1.00
head field_arithmetic_get_square_benchmark 1.088 ± 0.004 1.084 1.097 1.04 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 5.948 ± 0.031 5.908 5.995 1.00
head integration_builtins 6.146 ± 0.027 6.109 6.189 1.03 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 6.098 ± 0.030 6.055 6.150 1.00
head keccak_integration_benchmark 6.309 ± 0.092 6.245 6.556 1.03 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base linear_search 2.284 ± 0.016 2.265 2.322 1.00
head linear_search 2.369 ± 0.009 2.353 2.387 1.04 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 1.565 ± 0.012 1.544 1.584 1.00
head math_cmp_and_pow_integration_benchmark 1.588 ± 0.010 1.573 1.602 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 1.474 ± 0.011 1.457 1.490 1.00
head math_integration_benchmark 1.511 ± 0.009 1.502 1.526 1.02 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 1.297 ± 0.007 1.291 1.309 1.00
head memory_integration_benchmark 1.326 ± 0.010 1.317 1.345 1.02 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 1.435 ± 0.007 1.426 1.452 1.00
head operations_with_data_structures_benchmarks 1.470 ± 0.006 1.460 1.483 1.02 ± 0.01
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 581.6 ± 3.0 577.0 587.5 1.00
head pedersen 597.7 ± 2.7 592.8 601.4 1.03 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base poseidon_integration_benchmark 1.177 ± 0.012 1.165 1.207 1.00
head poseidon_integration_benchmark 1.179 ± 0.007 1.171 1.195 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 2.011 ± 0.021 1.991 2.061 1.00
head secp_integration_benchmark 2.035 ± 0.013 2.022 2.063 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base set_integration_benchmark 1.153 ± 0.003 1.144 1.156 1.00
head set_integration_benchmark 1.162 ± 0.004 1.156 1.167 1.01 ± 0.00
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 3.830 ± 0.020 3.805 3.858 1.00
head uint256_integration_benchmark 3.969 ± 0.028 3.936 4.031 1.04 ± 0.01
codecov[bot] commented 10 months ago

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (4089b46) 96.81% compared to head (8ca276f) 96.82%.

Files Patch % Lines
vm/src/vm/trace/mod.rs 84.61% 2 Missing :warning:
vm/src/vm/runners/cairo_runner.rs 98.93% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1492 +/- ## ======================================= Coverage 96.81% 96.82% ======================================= Files 96 96 Lines 39525 39567 +42 ======================================= + Hits 38267 38311 +44 + Misses 1258 1256 -2 ```

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