YJIT Benchmarks

2022-08-16 05:14:59

As of 2022-08-16 05:14:59:

Overall YJIT is 35.5% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 34.8% faster than CRuby!

The basic "faster" measurement is the geomean of all "headlining" benchmarks on this page.

Headlining Benchmarks

These are "headlining" because the "overall" speedup above is based on these benchmarks specifically.

0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 No JIT MJIT YJIT activerecord hexapdf liquid-render mail psych-load railsbench Speed of each Ruby implementation (iterations/second) relative to the CRuby interpreter. Higher is better.

MicroBenchmarks

0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 No JIT MJIT YJIT 30k_ifelse 30k_methods cfunc_itself fib getivar keyword_args respond_to setivar str_concat Speed of each Ruby implementation (iterations/second) relative to the CRuby interpreter. Higher is better.

Other Benchmarks

0.0 0.5 1.0 1.5 2.0 No JIT MJIT YJIT binarytrees chunky_png erubi erubi_rails fannkuchredux lee nbody optcarrot rubykon Speed of each Ruby implementation (iterations/second) relative to the CRuby interpreter. Higher is better.

Want Raw Graphs and CSV?

Benchmarks Speed Details

The y axis is CRuby's pure-interpreter time for the benchmark divided by the named interpreter's time (YJIT, MJIT, TruffleRuby). Taller bars mean better performance. Each benchmark is scaled to the CRuby's interpreter's mean result, so CRuby's results are always exactly 1.0.

bench No JIT (ms) No JIT RSD MJIT (ms) MJIT RSD YJIT (ms) YJIT RSD MJIT spd MJIT spd RSD YJIT spd YJIT spd RSD % in YJIT
activerecord 154.6 0.32% 155.9 0.34% 104.7 0.51% 0.99x 0.46% 1.48x 0.60% 85.96%
hexapdf 3228.4 1.05% 2372.9 2.85% 1.36x 3.04% 83.47%
liquid-render 196.7 0.98% 170.2 1.64% 127.6 1.79% 1.16x 1.91% 1.54x 2.05% 85.90%
mail 177.8 0.19% 174.1 1.78% 156.0 0.17% 1.02x 1.79% 1.14x 0.26% 99.26%
psych-load 2511.7 0.02% 2192.6 0.04% 1926.6 0.02% 1.15x 0.05% 1.30x 0.03% 88.89%
railsbench 2821.8 0.42% 2850.4 0.62% 2093.5 0.74% 0.99x 0.75% 1.35x 0.85% 86.54%
binarytrees 472.6 0.08% 332.6 0.41% 371.8 0.08% 1.42x 0.42% 1.27x 0.11% 84.27%
chunky_png 984.4 0.02% 794.1 0.43% 661.4 0.07% 1.24x 0.44% 1.49x 0.07% 99.95%
erubi 374.1 0.74% 347.5 0.62% 328.9 0.81% 1.08x 0.96% 1.14x 1.10% 100.00%
erubi_rails 27.3 2.61% 27.1 2.58% 19.3 3.30% 1.01x 3.67% 1.42x 4.21% 86.40%
fannkuchredux 5362.2 0.08% 2545.3 0.04% 2332.5 0.17% 2.11x 0.09% 2.30x 0.19% 77.42%
lee 1276.0 1.30% 1053.5 1.37% 953.8 1.26% 1.21x 1.89% 1.34x 1.81% 99.97%
nbody 143.0 0.06% 76.7 0.28% 89.1 0.09% 1.87x 0.29% 1.61x 0.11% 100.00%
optcarrot 6559.3 0.44% 2787.8 0.60% 3440.0 0.62% 2.35x 0.74% 1.91x 0.76% 96.16%
rubykon 12561.0 0.74% 8211.1 0.66% 6993.2 0.45% 1.53x 0.99% 1.80x 0.87% 99.76%
30k_ifelse 2392.1 0.01% 3683.5 3.85% 396.6 0.08% 0.65x 3.85% 6.03x 0.08% 100.00%
30k_methods 6631.9 0.01% 9809.4 19.46% 871.1 0.02% 0.68x 19.46% 7.61x 0.02% 100.00%
cfunc_itself 108.0 0.31% 70.1 0.66% 47.0 0.70% 1.54x 0.73% 2.30x 0.76% 100.00%
fib 234.0 0.13% 86.2 0.19% 63.4 0.07% 2.71x 0.23% 3.69x 0.15% 100.00%
getivar 124.8 0.46% 31.3 55.46% 44.2 0.05% 3.99x 55.46% 2.82x 0.47% 99.03%
keyword_args 282.1 0.12% 228.3 0.33% 55.5 0.18% 1.24x 0.35% 5.08x 0.22% 100.00%
respond_to 284.6 0.52% 246.1 0.58% 192.9 0.14% 1.16x 0.78% 1.48x 0.53% 100.00%
setivar 83.5 0.26% 20.2 61.49% 40.5 0.21% 4.13x 61.50% 2.06x 0.33% 99.17%
str_concat 82.8 1.00% 51.3 1.68% 44.5 1.48% 1.61x 1.96% 1.86x 1.78% 99.87%

RSD is relative standard deviation - the standard deviation divided by the mean, expressed as a percentage.
% in YJIT is the percentage of instructions that complete in YJIT rather than exiting to the non-JITted interpreter. YJIT performs better when this is higher.
Speedup is relative to interpreted CRuby. So an "MJIT speedup" of 1.21x means MJIT runs at 1.21 times the iters/second of CRuby with JIT disabled.

You can find our benchmark code in the yjit-bench Github repo and the yjit-extra-benchmarks Github repo.
Our benchmark-runner and reporting code is in the yjit-metrics Github repo.

Tested Ruby version for YJIT and No-JIT: ruby 3.2.0dev (2022-08-15T23:14:12Z master 0608a9a086) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-08-15T23:14:12Z master 0608a9a086) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 64 65 76
hexapdf 285 417
liquid-render 31 35 37
mail 49 53 56
psych-load 35 46 40
railsbench 104 107 133
binarytrees 28 32 30
chunky_png 41 47 46
erubi 94 102 116
erubi_rails 103 103 122
fannkuchredux 24 27 27
lee 32 39 41
nbody 24 26 27
optcarrot 63 70 68
rubykon 52 59 57
30k_ifelse 66 168 122
30k_methods 59 180 79
cfunc_itself 24 27 27
fib 24 27 26
getivar 24 26 27
keyword_args 24 27 27
respond_to 24 27 26
setivar 24 26 27
str_concat 98 110 109

Memory is shown in mebibytes (1024 * 1024 bytes.)

Older YJIT allocated an additional 256MiB for generated code. Current YJIT allocates executable memory on demand, so this overhead should no longer be present.

Number of Iterations and Warmups Tested

bench No JIT warmups No JIT iters MJIT warmups MJIT iters YJIT warmups YJIT iters
activerecord 5 195 75 195 20 195
hexapdf 5 15 20 15
liquid-render 5 157 75 157 20 157
mail 5 128 75 128 20 128
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 61 75 61 20 61
chunky_png 5 30 75 30 20 30
erubi 5 61 75 61 20 61
erubi_rails 5 1035 75 1035 20 1035
fannkuchredux 5 15 75 15 20 15
lee 5 20 75 20 20 20
nbody 5 263 75 263 20 263
optcarrot 5 15 75 15 20 15
rubykon 5 15 34 15 20 15
30k_ifelse 5 56 75 56 20 56
30k_methods 5 23 30 23 20 23
cfunc_itself 5 430 75 430 20 430
fib 5 315 75 315 20 315
getivar 5 619 75 619 20 619
keyword_args 5 368 75 368 20 368
respond_to 5 108 75 108 20 108
setivar 5 991 75 991 20 991
str_concat 5 452 75 452 20 452

Different Ruby configurations want different amounts of warmup. With no JIT, CRuby needs hardly any. YJIT and MJIT 3.0 both warm up quite quickly, while MJIT in 3.1 often slows down for a time as it compiles, after an unpredictable delay.

Benchmark YJIT Stats

Hover your cursor over the column headings for descriptions of each statistic.

bench Exit Report Inline Outlined Comp iSeqs Comp Blocks Inval Inval Ratio Bind Alloc Bind Set Const Bumps
activerecord (click) 1037723 780620 131 1295 0 0% 0 0 0
hexapdf (click) 1149915 923589 682 8012 9 0% 0 0 0
liquid-render (click) 521179 405913 150 1709 2 0% 0 0 0
mail (click) 897115 647805 374 5304 17 0% 0 0 0
psych-load (click) 347995 264036 68 480 1 0% 0 0 0
railsbench (click) 2658843 1968351 1436 10047 16 0% 0 0 0
binarytrees (click) 171611 127963 13 58 0 0% 0 0 0
chunky_png (click) 385051 288171 88 990 0 0% 0 0 0
erubi (click) 322779 245914 10 79 0 0% 0 0 0
erubi_rails (click) 1961051 1428196 300 2011 4 0% 0 0 0
fannkuchredux (click) 185371 137720 10 196 0 0% 0 0 0
lee (click) 385179 290709 58 632 0 0% 0 0 0
nbody (click) 182491 137443 12 171 0 0% 0 0 0
optcarrot (click) 513883 442610 207 3588 20 0% 0 0 0
rubykon (click) 320027 256436 144 1565 1 0% 0 0 0
30k_ifelse (click) 5560475 4348420 9265 57804 0 0% 0 0 0
30k_methods (click) 2175643 1656882 5784 19361 0 0% 0 0 0
cfunc_itself (click) 169947 126725 10 49 0 0% 0 0 0
fib (click) 168859 126629 10 38 0 0% 0 0 0
getivar (click) 170587 128716 10 65 0 0% 0 0 0
keyword_args (click) 171227 127662 11 51 0 0% 0 0 0
respond_to (click) 172507 128475 10 64 0 0% 0 0 0
setivar (click) 170075 127240 10 38 0 0% 0 0 0
str_concat (click) 170523 127868 12 62 0 0% 0 0 0

YJIT stats correspond to the YJIT stats exit report.

Raw JSON data files

All graphs and table data in this page comes from processing these data files, which come from benchmark runs.