cairo_native icon indicating copy to clipboard operation
cairo_native copied to clipboard

Add benchmarks comparing to Cairo VM

Open JulianGCalderon opened this issue 1 year ago • 3 comments

This PR benchmarks cairo native against cairo vm with criterion:

  • Benchmarks cairo VM with fibonacci, factorial, and logistic map programs.
  • Groups the benchmarks by program

Compile time is not taken into account for cairo native runs.

Benchmarking Server

Factorial:

factorial_2M/Cached JIT time:   [290.86 ms 291.00 ms 291.15 ms]
Found 3 outliers among 100 measurements (3.00%)
  1 (1.00%) high mild
  2 (2.00%) high severe

factorial_2M/Cached AOT time:   [904.06 ms 906.65 ms 909.17 ms]

factorial_2M/VM         time:   [3.7880 s 3.8034 s 3.8197 s]
Found 2 outliers among 100 measurements (2.00%)
  1 (1.00%) high mild
  1 (1.00%) high severe

Fibonacci:

fibonacci_2M/Cached JIT time:   [6.8784 ms 6.8821 ms 6.8864 ms]
Found 5 outliers among 100 measurements (5.00%)
  5 (5.00%) high severe

fibonacci_2M/Cached AOT time:   [18.645 ms 18.665 ms 18.688 ms]
Found 13 outliers among 100 measurements (13.00%)
  2 (2.00%) low severe
  11 (11.00%) high severe

fibonacci_2M/VM         time:   [3.4395 s 3.4521 s 3.4659 s]
Found 3 outliers among 100 measurements (3.00%)
  3 (3.00%) high severe

Logistic Map:

logistic_map/Cached JIT time:   [45.216 ms 45.244 ms 45.274 ms]
Found 13 outliers among 100 measurements (13.00%)
  8 (8.00%) high mild
  5 (5.00%) high severe

logistic_map/Cached AOT time:   [163.22 ms 163.48 ms 163.76 ms]
Found 16 outliers among 100 measurements (16.00%)
  16 (16.00%) high mild

logistic_map/VM         time:   [37.747 ms 37.778 ms 37.811 ms]
Found 6 outliers among 100 measurements (6.00%)
  5 (5.00%) high mild
  1 (1.00%) high severe

Macbook Air M1

factorial_2M/Cached JIT
                        time:   [271.52 ms 272.40 ms 274.08 ms]
factorial_2M/Cached AOT
                        time:   [734.26 ms 736.76 ms 740.13 ms]
factorial_2M/VM
                        time:   [3.9340 s 3.9436 s 3.9551 s]

fibonacci_2M/Cached JIT
                        time:   [7.6131 ms 7.6222 ms 7.6349 ms]
fibonacci_2M/Cached AOT
                        time:   [17.554 ms 17.562 ms 17.571 ms]
fibonacci_2M/VM
                        time:   [3.7504 s 3.7533 s 3.7565 s]

logistic_map/Cached JIT
                        time:   [45.113 ms 45.124 ms 45.136 ms]
logistic_map/Cached AOT
                        time:   [126.11 ms 126.17 ms 126.25 ms]
logistic_map/VM
                        time:   [42.685 ms 42.710 ms 42.735 ms]

JulianGCalderon avatar Jun 18 '24 15:06 JulianGCalderon

Benchmark results Main vs HEAD.

Command Mean [s] Min [s] Max [s] Relative
base factorial_2M.cairo (JIT) 3.378 ± 0.039 3.328 3.444 1.00
base factorial_2M.cairo (AOT) 3.463 ± 0.067 3.370 3.579 1.03 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
:--- ---: ---: ---: ---:
head factorial_2M.cairo (JIT) 3.228 ± 0.020 3.206 3.266 1.00
head factorial_2M.cairo (AOT) 3.397 ± 0.029 3.356 3.434 1.05 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base fib_2M.cairo (JIT) 2.753 ± 0.013 2.734 2.770 1.00
base fib_2M.cairo (AOT) 2.974 ± 0.044 2.932 3.058 1.08 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
:--- ---: ---: ---: ---:
head fib_2M.cairo (JIT) 2.734 ± 0.020 2.713 2.774 1.00
head fib_2M.cairo (AOT) 2.933 ± 0.016 2.904 2.952 1.07 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base logistic_map.cairo (JIT) 3.073 ± 0.042 3.026 3.164 1.00
base logistic_map.cairo (AOT) 3.112 ± 0.019 3.091 3.152 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
:--- ---: ---: ---: ---:
head logistic_map.cairo (JIT) 3.182 ± 0.091 3.063 3.318 1.01 ± 0.03
head logistic_map.cairo (AOT) 3.165 ± 0.046 3.106 3.262 1.00

github-actions[bot] avatar Jun 18 '24 15:06 github-actions[bot]

Codecov Report

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

Project coverage is 82.54%. Comparing base (20e1d9f) to head (abdfcbd).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #692   +/-   ##
=======================================
  Coverage   82.54%   82.54%           
=======================================
  Files         117      117           
  Lines       33516    33516           
=======================================
+ Hits        27665    27666    +1     
+ Misses       5851     5850    -1     

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

codecov-commenter avatar Jun 21 '24 13:06 codecov-commenter

Other thing to take into account, maybe is easier to benchmark a contract execution

pefontana avatar Jul 06 '24 15:07 pefontana

Benchmarking results

Benchmark for program factorial_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 11.598 ± 0.294 10.850 11.899 8.61 ± 0.22
cairo-native (embedded AOT) 3.579 ± 0.034 3.544 3.641 2.66 ± 0.03
cairo-native (embedded JIT using LLVM's ORC Engine) 3.380 ± 0.036 3.349 3.450 2.51 ± 0.03
cairo-native (standalone AOT with -march=native) 1.347 ± 0.001 1.345 1.349 1.00

Benchmark for program fib_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 10.936 ± 0.264 10.623 11.452 140.04 ± 3.39
cairo-native (embedded AOT) 3.102 ± 0.016 3.076 3.139 39.72 ± 0.22
cairo-native (embedded JIT using LLVM's ORC Engine) 2.918 ± 0.038 2.872 3.001 37.36 ± 0.49
cairo-native (standalone AOT with -march=native) 0.078 ± 0.000 0.078 0.078 1.00

Benchmark for program linear_search

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 4.552 ± 0.027 4.514 4.591 115.94 ± 11.87
cairo-native (embedded AOT) 3.222 ± 0.030 3.194 3.297 82.06 ± 8.42
cairo-native (embedded JIT using LLVM's ORC Engine) 3.105 ± 0.015 3.081 3.136 79.09 ± 8.09
cairo-native (standalone AOT with -march=native) 0.039 ± 0.004 0.036 0.054 1.00

Benchmark for program logistic_map

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 4.435 ± 0.044 4.367 4.496 18.29 ± 0.18
cairo-native (embedded AOT) 3.274 ± 0.018 3.253 3.307 13.50 ± 0.08
cairo-native (embedded JIT using LLVM's ORC Engine) 3.221 ± 0.025 3.196 3.267 13.28 ± 0.10
cairo-native (standalone AOT with -march=native) 0.242 ± 0.000 0.242 0.243 1.00

github-actions[bot] avatar Nov 07 '24 17:11 github-actions[bot]