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 133 forks source link

Set dynamic params as null by default on air public input #1716

Closed fmoletta closed 2 months ago

fmoletta commented 2 months ago

Closes #1649 dynamic_params are always set to null on the cairo_lang implementation, even if these were to be added in the future, the structure of these params is different to that of CairoLayout, so it doesn't make much sense to keep serializing this struct. This PR removes the CairoLayout type from the dynamic_params field of AirPublicInput, replacing it with a () type that serializes as null. This also removes the lifetime from dynamic_params, allowing us to use a representation that is not tied to a lifetime in the layout field (Such as the enum added by #1715)

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 94.81%. Comparing base (a462d8d) to head (dce5188).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1716 +/- ## ======================================= Coverage 94.80% 94.81% ======================================= Files 100 100 Lines 38214 38207 -7 ======================================= - Hits 36228 36225 -3 + Misses 1986 1982 -4 ```

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

github-actions[bot] commented 2 months ago

Benchmark Results for unmodified programs :rocket:

Command Mean [s] Min [s] Max [s] Relative
base big_factorial 1.933 ± 0.040 1.897 2.021 1.00 ± 0.03
head big_factorial 1.931 ± 0.028 1.903 1.981 1.00
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 1.858 ± 0.030 1.823 1.923 1.00
head big_fibonacci 1.874 ± 0.067 1.828 2.045 1.01 ± 0.04
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 6.501 ± 0.146 6.365 6.816 1.00 ± 0.02
head blake2s_integration_benchmark 6.475 ± 0.061 6.351 6.559 1.00
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 1.926 ± 0.051 1.879 2.044 1.00
head compare_arrays_200000 1.945 ± 0.044 1.899 2.056 1.01 ± 0.04
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 1.314 ± 0.016 1.302 1.349 1.00
head dict_integration_benchmark 1.315 ± 0.012 1.299 1.334 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.162 ± 0.013 1.149 1.188 1.01 ± 0.01
head field_arithmetic_get_square_benchmark 1.149 ± 0.007 1.140 1.159 1.00
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 6.505 ± 0.081 6.428 6.686 1.00
head integration_builtins 6.540 ± 0.094 6.447 6.693 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 6.891 ± 0.242 6.635 7.377 1.02 ± 0.04
head keccak_integration_benchmark 6.724 ± 0.081 6.636 6.887 1.00
Command Mean [s] Min [s] Max [s] Relative
base linear_search 1.998 ± 0.064 1.942 2.153 1.02 ± 0.03
head linear_search 1.957 ± 0.015 1.934 1.983 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 1.694 ± 0.018 1.666 1.717 1.00
head math_cmp_and_pow_integration_benchmark 1.695 ± 0.018 1.668 1.732 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 1.481 ± 0.036 1.445 1.570 1.00 ± 0.03
head math_integration_benchmark 1.480 ± 0.028 1.458 1.553 1.00
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 1.155 ± 0.024 1.130 1.205 1.01 ± 0.03
head memory_integration_benchmark 1.144 ± 0.021 1.121 1.193 1.00
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 1.783 ± 0.019 1.761 1.833 1.00
head operations_with_data_structures_benchmarks 1.791 ± 0.041 1.759 1.873 1.00 ± 0.03
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 513.9 ± 8.6 504.0 534.9 1.01 ± 0.02
head pedersen 508.8 ± 3.0 503.6 513.9 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base poseidon_integration_benchmark 970.1 ± 22.2 948.4 1026.4 1.01 ± 0.02
head poseidon_integration_benchmark 962.5 ± 4.6 955.6 968.4 1.00
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 1.758 ± 0.030 1.734 1.822 1.01 ± 0.02
head secp_integration_benchmark 1.743 ± 0.015 1.724 1.774 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base set_integration_benchmark 719.2 ± 5.0 709.5 725.6 1.03 ± 0.01
head set_integration_benchmark 697.0 ± 8.6 688.8 719.0 1.00
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 3.820 ± 0.083 3.716 3.947 1.00 ± 0.02
head uint256_integration_benchmark 3.801 ± 0.037 3.740 3.839 1.00
github-actions[bot] commented 2 months 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 ± σ):     23.680 s ±  0.083 s    [User: 22.979 s, System: 0.699 s]
  Range (min … max):   23.621 s … 23.739 s    2 runs

Benchmark 2: hyper_threading_pr threads: 1
  Time (mean ± σ):     23.775 s ±  0.014 s    [User: 23.004 s, System: 0.770 s]
  Range (min … max):   23.765 s … 23.785 s    2 runs

Summary
  'hyper_threading_main threads: 1' ran
    1.00 ± 0.00 times faster than 'hyper_threading_pr 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 ± σ):     12.323 s ±  0.106 s    [User: 23.254 s, System: 0.701 s]
  Range (min … max):   12.248 s … 12.398 s    2 runs

Benchmark 2: hyper_threading_pr threads: 2
  Time (mean ± σ):     12.353 s ±  0.021 s    [User: 23.426 s, System: 0.755 s]
  Range (min … max):   12.338 s … 12.368 s    2 runs

Summary
  'hyper_threading_main threads: 2' ran
    1.00 ± 0.01 times faster than 'hyper_threading_pr 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.065 s ±  0.295 s    [User: 35.026 s, System: 0.899 s]
  Range (min … max):    9.856 s … 10.273 s    2 runs

Benchmark 2: hyper_threading_pr threads: 4
  Time (mean ± σ):      9.806 s ±  0.121 s    [User: 34.933 s, System: 0.901 s]
  Range (min … max):    9.720 s …  9.892 s    2 runs

Summary
  'hyper_threading_pr threads: 4' ran
    1.03 ± 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 ± σ):      9.590 s ±  0.153 s    [User: 35.311 s, System: 0.985 s]
  Range (min … max):    9.482 s …  9.698 s    2 runs

Benchmark 2: hyper_threading_pr threads: 6
  Time (mean ± σ):      9.732 s ±  0.134 s    [User: 34.979 s, System: 0.966 s]
  Range (min … max):    9.637 s …  9.826 s    2 runs

Summary
  'hyper_threading_main threads: 6' ran
    1.01 ± 0.02 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 ± σ):      9.667 s ±  0.109 s    [User: 35.332 s, System: 0.970 s]
  Range (min … max):    9.590 s …  9.744 s    2 runs

Benchmark 2: hyper_threading_pr threads: 8
  Time (mean ± σ):      9.647 s ±  0.150 s    [User: 35.075 s, System: 1.001 s]
  Range (min … max):    9.541 s …  9.753 s    2 runs

Summary
  'hyper_threading_pr threads: 8' ran
    1.00 ± 0.02 times faster than 'hyper_threading_main 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 ± σ):      9.474 s ±  0.042 s    [User: 35.892 s, System: 1.077 s]
  Range (min … max):    9.444 s …  9.503 s    2 runs

Benchmark 2: hyper_threading_pr threads: 16
  Time (mean ± σ):      9.478 s ±  0.192 s    [User: 35.488 s, System: 1.084 s]
  Range (min … max):    9.342 s …  9.614 s    2 runs

Summary
  'hyper_threading_main threads: 16' ran
    1.00 ± 0.02 times faster than 'hyper_threading_pr threads: 16'