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
514 stars 144 forks source link

Move dict finalization to `FinalizeDict` Hint #1774

Closed fmoletta closed 4 months ago

fmoletta commented 4 months ago

This changes depend on the compiler changes in fork branch https://github.com/lambdaclass/cairo/tree/finalize-dict-hint-sierra-v1.5.0 Modifies DictManager.finalize_segment so that it relocates the current dictionary instead of relocating the next one. Implements the new FinalizeDict hint

github-actions[bot] commented 4 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 ± σ):     28.006 s ±  0.056 s    [User: 27.200 s, System: 0.804 s]
  Range (min … max):   27.966 s … 28.045 s    2 runs

Benchmark 2: hyper_threading_pr threads: 1
  Time (mean ± σ):     27.267 s ±  0.062 s    [User: 26.492 s, System: 0.773 s]
  Range (min … max):   27.223 s … 27.310 s    2 runs

Summary
  'hyper_threading_pr threads: 1' ran
    1.03 ± 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.124 s ±  0.008 s    [User: 27.553 s, System: 0.790 s]
  Range (min … max):   15.119 s … 15.130 s    2 runs

Benchmark 2: hyper_threading_pr threads: 2
  Time (mean ± σ):     14.817 s ±  0.007 s    [User: 27.003 s, System: 0.811 s]
  Range (min … max):   14.812 s … 14.822 s    2 runs

Summary
  'hyper_threading_pr threads: 2' ran
    1.02 ± 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.307 s ±  0.167 s    [User: 39.392 s, System: 0.986 s]
  Range (min … max):   11.189 s … 11.425 s    2 runs

Benchmark 2: hyper_threading_pr threads: 4
  Time (mean ± σ):     10.876 s ±  0.404 s    [User: 38.980 s, System: 0.966 s]
  Range (min … max):   10.591 s … 11.162 s    2 runs

Summary
  'hyper_threading_pr threads: 4' ran
    1.04 ± 0.04 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 ± σ):     11.101 s ±  0.097 s    [User: 39.471 s, System: 0.982 s]
  Range (min … max):   11.033 s … 11.170 s    2 runs

Benchmark 2: hyper_threading_pr threads: 6
  Time (mean ± σ):     10.976 s ±  0.116 s    [User: 38.898 s, System: 0.991 s]
  Range (min … max):   10.894 s … 11.058 s    2 runs

Summary
  'hyper_threading_pr threads: 6' ran
    1.01 ± 0.01 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.649 s ±  0.039 s    [User: 39.829 s, System: 0.980 s]
  Range (min … max):   10.622 s … 10.677 s    2 runs

Benchmark 2: hyper_threading_pr threads: 8
  Time (mean ± σ):     10.657 s ±  0.018 s    [User: 39.091 s, System: 1.113 s]
  Range (min … max):   10.644 s … 10.669 s    2 runs

Summary
  'hyper_threading_main threads: 8' ran
    1.00 ± 0.00 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.800 s ±  0.381 s    [User: 40.116 s, System: 1.104 s]
  Range (min … max):   10.530 s … 11.069 s    2 runs

Benchmark 2: hyper_threading_pr threads: 16
  Time (mean ± σ):     10.625 s ±  0.333 s    [User: 39.661 s, System: 1.067 s]
  Range (min … max):   10.390 s … 10.860 s    2 runs

Summary
  'hyper_threading_pr threads: 16' ran
    1.02 ± 0.05 times faster than 'hyper_threading_main threads: 16'
github-actions[bot] commented 4 months ago

Benchmark Results for unmodified programs :rocket:

Command Mean [s] Min [s] Max [s] Relative
base big_factorial 2.069 ± 0.058 2.004 2.181 1.00 ± 0.04
head big_factorial 2.059 ± 0.058 2.014 2.207 1.00
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 1.994 ± 0.033 1.954 2.036 1.00 ± 0.02
head big_fibonacci 1.986 ± 0.026 1.959 2.044 1.00
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 7.587 ± 0.090 7.468 7.757 1.00
head blake2s_integration_benchmark 7.675 ± 0.467 7.433 8.970 1.01 ± 0.06
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 2.157 ± 0.040 2.119 2.234 1.00 ± 0.02
head compare_arrays_200000 2.147 ± 0.026 2.117 2.191 1.00
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 1.430 ± 0.011 1.422 1.453 1.00
head dict_integration_benchmark 1.446 ± 0.025 1.426 1.504 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.291 ± 0.015 1.275 1.325 1.00
head field_arithmetic_get_square_benchmark 1.294 ± 0.013 1.279 1.316 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 7.592 ± 0.114 7.461 7.829 1.00
head integration_builtins 7.660 ± 0.119 7.559 7.860 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 7.778 ± 0.122 7.678 8.008 1.00
head keccak_integration_benchmark 7.859 ± 0.172 7.699 8.285 1.01 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base linear_search 2.075 ± 0.032 2.035 2.120 1.00
head linear_search 2.090 ± 0.053 2.051 2.226 1.01 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 1.682 ± 0.019 1.670 1.734 1.00
head math_cmp_and_pow_integration_benchmark 1.690 ± 0.010 1.677 1.706 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 1.593 ± 0.022 1.576 1.650 1.00
head math_integration_benchmark 1.600 ± 0.012 1.582 1.621 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 1.194 ± 0.037 1.168 1.292 1.00 ± 0.03
head memory_integration_benchmark 1.194 ± 0.013 1.180 1.217 1.00
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 1.804 ± 0.010 1.789 1.820 1.00 ± 0.01
head operations_with_data_structures_benchmarks 1.803 ± 0.015 1.789 1.840 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 514.6 ± 3.6 509.8 521.4 1.01 ± 0.01
head pedersen 511.1 ± 2.4 508.6 516.6 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base poseidon_integration_benchmark 951.0 ± 5.2 941.7 956.8 1.00 ± 0.01
head poseidon_integration_benchmark 950.2 ± 2.9 944.5 954.2 1.00
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 1.853 ± 0.010 1.840 1.867 1.00 ± 0.01
head secp_integration_benchmark 1.848 ± 0.013 1.829 1.867 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base set_integration_benchmark 637.0 ± 3.7 632.7 645.2 1.00
head set_integration_benchmark 641.2 ± 3.0 637.3 647.9 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 4.181 ± 0.109 4.089 4.387 1.00
head uint256_integration_benchmark 4.213 ± 0.068 4.092 4.312 1.01 ± 0.03
codecov[bot] commented 4 months ago

Codecov Report

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

Project coverage is 94.79%. Comparing base (f4a2214) to head (2ab76c9). Report is 3 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1774 +/- ## ======================================== Coverage 94.79% 94.79% ======================================== Files 101 101 Lines 38889 38994 +105 ======================================== + Hits 36863 36963 +100 - Misses 2026 2031 +5 ```

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

fmoletta commented 4 months ago

Closed in favor of #1776