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
522 stars 150 forks source link

Missing dynamic layout features #1838

Closed JulianGCalderon closed 1 month ago

JulianGCalderon commented 2 months ago

Missing dynamic layout features

Solves #1834

Features

Checklist

github-actions[bot] commented 2 months ago

Benchmark Results for unmodified programs :rocket:

Command Mean [s] Min [s] Max [s] Relative
base big_factorial 2.356 ± 0.035 2.306 2.435 1.00
head big_factorial 2.451 ± 0.055 2.401 2.582 1.04 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 2.263 ± 0.031 2.221 2.328 1.00
head big_fibonacci 2.370 ± 0.019 2.347 2.405 1.05 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 8.162 ± 0.071 8.057 8.237 1.00
head blake2s_integration_benchmark 8.655 ± 0.222 8.459 9.009 1.06 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 2.424 ± 0.043 2.357 2.507 1.00
head compare_arrays_200000 2.520 ± 0.045 2.477 2.636 1.04 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 1.612 ± 0.037 1.578 1.706 1.00
head dict_integration_benchmark 1.655 ± 0.036 1.628 1.754 1.03 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.325 ± 0.011 1.307 1.335 1.00
head field_arithmetic_get_square_benchmark 1.393 ± 0.020 1.367 1.429 1.05 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 8.267 ± 0.071 8.093 8.352 1.00
head integration_builtins 8.783 ± 0.162 8.555 8.980 1.06 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 8.609 ± 0.311 8.321 9.413 1.00
head keccak_integration_benchmark 9.181 ± 0.303 8.878 9.718 1.07 ± 0.05
Command Mean [s] Min [s] Max [s] Relative
base linear_search 2.416 ± 0.049 2.361 2.537 1.00
head linear_search 2.493 ± 0.024 2.471 2.540 1.03 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 1.680 ± 0.010 1.657 1.691 1.00
head math_cmp_and_pow_integration_benchmark 1.717 ± 0.014 1.709 1.756 1.02 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 1.627 ± 0.023 1.606 1.684 1.00
head math_integration_benchmark 1.671 ± 0.015 1.655 1.702 1.03 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 1.358 ± 0.027 1.324 1.416 1.00
head memory_integration_benchmark 1.404 ± 0.010 1.393 1.422 1.03 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 1.751 ± 0.030 1.727 1.835 1.00
head operations_with_data_structures_benchmarks 1.791 ± 0.019 1.771 1.819 1.02 ± 0.02
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 565.2 ± 3.8 560.1 571.3 1.00
head pedersen 578.7 ± 2.9 575.3 584.2 1.02 ± 0.01
Command Mean [ms] Min [ms] Max [ms] Relative
base poseidon_integration_benchmark 689.1 ± 14.9 676.2 722.6 1.00
head poseidon_integration_benchmark 698.4 ± 16.3 682.0 740.1 1.01 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 1.956 ± 0.032 1.932 2.018 1.00
head secp_integration_benchmark 2.015 ± 0.030 1.974 2.067 1.03 ± 0.02
Command Mean [ms] Min [ms] Max [ms] Relative
base set_integration_benchmark 671.8 ± 7.2 665.3 691.0 1.00
head set_integration_benchmark 701.6 ± 2.1 698.0 705.0 1.04 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 4.634 ± 0.052 4.559 4.718 1.00
head uint256_integration_benchmark 4.893 ± 0.174 4.768 5.358 1.06 ± 0.04
github-actions[bot] commented 2 months ago

Benchmark Results for modified programs :rocket:

Command Mean [s] Min [s] Max [s] Relative
head blake2s_integration_benchmark 8.684 ± 0.274 8.418 9.247 1.00
Command Mean [s] Min [s] Max [s] Relative
head compare_arrays_200000 2.522 ± 0.069 2.470 2.700 1.00
Command Mean [s] Min [s] Max [s] Relative
head dict_integration_benchmark 1.644 ± 0.035 1.628 1.744 1.00
Command Mean [s] Min [s] Max [s] Relative
head field_arithmetic_get_square_benchmark 1.369 ± 0.024 1.351 1.416 1.00
Command Mean [s] Min [s] Max [s] Relative
head integration_builtins 8.639 ± 0.129 8.519 8.935 1.00
Command Mean [s] Min [s] Max [s] Relative
head keccak_integration_benchmark 8.894 ± 0.149 8.745 9.198 1.00
Command Mean [s] Min [s] Max [s] Relative
head linear_search 2.495 ± 0.045 2.453 2.595 1.00
Command Mean [s] Min [s] Max [s] Relative
head math_cmp_and_pow_integration_benchmark 1.709 ± 0.024 1.696 1.776 1.00
Command Mean [s] Min [s] Max [s] Relative
head math_integration_benchmark 1.652 ± 0.008 1.642 1.669 1.00
Command Mean [s] Min [s] Max [s] Relative
head memory_integration_benchmark 1.390 ± 0.004 1.383 1.394 1.00
Command Mean [s] Min [s] Max [s] Relative
head operations_with_data_structures_benchmarks 1.756 ± 0.006 1.746 1.764 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
head pedersen 580.2 ± 8.6 575.0 603.9 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
head poseidon_integration_benchmark 678.5 ± 7.2 669.1 693.8 1.00
Command Mean [s] Min [s] Max [s] Relative
head secp_integration_benchmark 2.003 ± 0.015 1.988 2.038 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
head set_integration_benchmark 701.6 ± 7.5 695.7 715.7 1.00
Command Mean [s] Min [s] Max [s] Relative
head uint256_integration_benchmark 4.795 ± 0.086 4.720 4.962 1.00
codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 96.18138% with 16 lines in your changes missing coverage. Please review.

Project coverage is 96.32%. Comparing base (14ec3e3) to head (a6e93da). Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
vm/src/vm/runners/builtin_runner/modulo.rs 94.15% 9 Missing :warning:
vm/src/vm/runners/cairo_runner.rs 71.42% 4 Missing :warning:
vm/src/types/layout.rs 95.91% 2 Missing :warning:
vm/src/vm/runners/builtin_runner/mod.rs 98.38% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1838 +/- ## ========================================== + Coverage 94.79% 96.32% +1.53% ========================================== Files 101 102 +1 Lines 39836 40381 +545 ========================================== + Hits 37762 38899 +1137 + Misses 2074 1482 -592 ``` | [Flag](https://app.codecov.io/gh/lambdaclass/cairo-vm/pull/1838/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=lambdaclass) | Coverage Δ | | |---|---|---| | [](https://app.codecov.io/gh/lambdaclass/cairo-vm/pull/1838/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=lambdaclass) | `?` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=lambdaclass#carryforward-flags-in-the-pull-request-comment) to find out more.

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

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 ± σ):     29.874 s ±  0.003 s    [User: 29.138 s, System: 0.735 s]
  Range (min … max):   29.872 s … 29.876 s    2 runs

Benchmark 2: hyper_threading_pr threads: 1
  Time (mean ± σ):     30.221 s ±  0.060 s    [User: 29.450 s, System: 0.768 s]
  Range (min … max):   30.179 s … 30.264 s    2 runs

Summary
  'hyper_threading_main threads: 1' ran
    1.01 ± 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 ± σ):     16.844 s ±  0.203 s    [User: 29.581 s, System: 0.764 s]
  Range (min … max):   16.700 s … 16.987 s    2 runs

Benchmark 2: hyper_threading_pr threads: 2
  Time (mean ± σ):     16.819 s ±  0.011 s    [User: 29.505 s, System: 0.795 s]
  Range (min … max):   16.811 s … 16.827 s    2 runs

Summary
  'hyper_threading_pr threads: 2' ran
    1.00 ± 0.01 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.717 s ±  0.372 s    [User: 41.089 s, System: 0.960 s]
  Range (min … max):   11.454 s … 11.980 s    2 runs

Benchmark 2: hyper_threading_pr threads: 4
  Time (mean ± σ):     11.506 s ±  0.346 s    [User: 42.111 s, System: 0.967 s]
  Range (min … max):   11.261 s … 11.750 s    2 runs

Summary
  'hyper_threading_pr threads: 4' ran
    1.02 ± 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.730 s ±  0.216 s    [User: 41.444 s, System: 0.936 s]
  Range (min … max):   11.577 s … 11.882 s    2 runs

Benchmark 2: hyper_threading_pr threads: 6
  Time (mean ± σ):     11.345 s ±  0.025 s    [User: 42.368 s, System: 0.956 s]
  Range (min … max):   11.328 s … 11.363 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 ± σ):     11.506 s ±  0.129 s    [User: 41.753 s, System: 0.935 s]
  Range (min … max):   11.416 s … 11.597 s    2 runs

Benchmark 2: hyper_threading_pr threads: 8
  Time (mean ± σ):     11.467 s ±  0.205 s    [User: 42.463 s, System: 0.936 s]
  Range (min … max):   11.323 s … 11.612 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 ± σ):     11.328 s ±  0.248 s    [User: 42.327 s, System: 1.032 s]
  Range (min … max):   11.152 s … 11.503 s    2 runs

Benchmark 2: hyper_threading_pr threads: 16
  Time (mean ± σ):     11.394 s ±  0.317 s    [User: 42.692 s, System: 1.028 s]
  Range (min … max):   11.170 s … 11.619 s    2 runs

Summary
  'hyper_threading_main threads: 16' ran
    1.01 ± 0.04 times faster than 'hyper_threading_pr threads: 16'