YJIT Benchmarks

2022-08-16 20:14:09

As of 2022-08-16 20:14:09:

Overall YJIT is 35.2% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 35.4% 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 156.9 0.41% 156.8 0.67% 105.0 0.67% 1.00x 0.78% 1.49x 0.79% 85.96%
hexapdf 3221.8 0.97% 2387.0 2.53% 1.35x 2.71% 83.56%
liquid-render 195.6 1.19% 170.4 1.66% 127.1 1.74% 1.15x 2.04% 1.54x 2.11% 85.90%
mail 177.2 0.13% 174.9 1.98% 156.3 0.18% 1.01x 1.99% 1.13x 0.22% 99.36%
psych-load 2446.4 0.07% 2160.7 0.13% 1906.5 0.03% 1.13x 0.15% 1.28x 0.08% 88.89%
railsbench 2820.8 0.76% 2823.0 0.22% 2083.1 0.44% 1.00x 0.79% 1.35x 0.88% 86.54%
binarytrees 477.0 0.12% 313.7 0.34% 371.2 0.08% 1.52x 0.36% 1.29x 0.15% 84.27%
chunky_png 985.7 0.04% 787.4 0.03% 654.2 0.04% 1.25x 0.05% 1.51x 0.05% 99.95%
erubi 372.0 0.63% 343.2 0.74% 328.8 0.89% 1.08x 0.97% 1.13x 1.09% 100.00%
erubi_rails 26.9 2.56% 28.2 2.36% 19.2 3.61% 0.95x 3.48% 1.40x 4.42% 86.41%
fannkuchredux 5367.2 0.07% 2411.0 0.12% 2353.3 0.62% 2.23x 0.14% 2.28x 0.63% 77.42%
lee 1285.0 1.38% 1063.4 1.64% 963.4 1.77% 1.21x 2.15% 1.33x 2.24% 99.97%
nbody 142.4 0.11% 76.6 0.25% 89.4 0.10% 1.86x 0.27% 1.59x 0.15% 100.00%
optcarrot 6612.4 0.42% 2767.6 0.62% 3441.1 0.58% 2.39x 0.75% 1.92x 0.72% 96.16%
rubykon 12700.7 0.45% 8172.5 0.97% 6862.2 0.51% 1.55x 1.07% 1.85x 0.68% 99.61%
30k_ifelse 2395.7 0.01% 3714.4 3.68% 356.7 0.10% 0.64x 3.68% 6.72x 0.10% 100.00%
30k_methods 6391.2 0.01% 10002.8 19.76% 875.6 0.02% 0.64x 19.76% 7.30x 0.02% 100.00%
cfunc_itself 108.0 0.30% 72.4 0.87% 48.6 0.75% 1.49x 0.92% 2.22x 0.81% 100.00%
fib 233.5 0.03% 86.2 0.37% 63.3 0.05% 2.71x 0.37% 3.69x 0.06% 100.00%
getivar 125.2 0.17% 31.7 56.53% 44.2 0.11% 3.95x 56.53% 2.83x 0.20% 99.06%
keyword_args 281.8 0.08% 226.3 0.73% 54.6 0.29% 1.25x 0.73% 5.16x 0.30% 100.00%
respond_to 276.3 0.07% 230.6 0.39% 192.1 0.08% 1.20x 0.40% 1.44x 0.11% 100.00%
setivar 83.4 0.34% 20.2 61.89% 40.4 0.56% 4.13x 61.89% 2.06x 0.66% 99.17%
str_concat 82.7 1.09% 51.6 1.51% 44.7 1.44% 1.60x 1.86% 1.85x 1.80% 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-16T15:58:56Z master ac890ec062) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-08-16T15:58:56Z master ac890ec062) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 65 65 77
hexapdf 266 412
liquid-render 30 35 37
mail 49 53 56
psych-load 36 45 40
railsbench 104 106 133
binarytrees 28 33 30
chunky_png 40 43 45
erubi 69 83 134
erubi_rails 103 103 123
fannkuchredux 24 27 26
lee 36 42 41
nbody 24 26 26
optcarrot 63 69 69
rubykon 52 58 55
30k_ifelse 66 161 122
30k_methods 58 180 79
cfunc_itself 24 26 26
fib 24 26 26
getivar 24 26 26
keyword_args 24 27 26
respond_to 24 27 26
setivar 24 26 27
str_concat 112 110 106

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 190 75 190 20 190
hexapdf 5 15 20 15
liquid-render 5 156 75 156 20 156
mail 5 128 75 128 20 128
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 60 75 60 20 60
chunky_png 5 30 75 30 20 30
erubi 5 60 75 60 20 60
erubi_rails 5 1035 75 1035 20 1035
fannkuchredux 5 15 75 15 20 15
lee 5 20 75 20 20 20
nbody 5 260 75 260 20 260
optcarrot 5 15 75 15 20 15
rubykon 5 15 36 15 20 15
30k_ifelse 5 50 75 50 20 50
30k_methods 5 22 30 22 20 22
cfunc_itself 5 425 75 425 20 425
fib 5 315 75 315 20 315
getivar 5 639 75 639 20 639
keyword_args 5 360 75 360 20 360
respond_to 5 103 75 103 20 103
setivar 5 988 75 988 20 988
str_concat 5 449 75 449 20 449

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) 1035355 778983 131 1278 0 0% 0 0 0
hexapdf (click) 1151707 925266 683 8033 9 0% 0 0 0
liquid-render (click) 520475 405004 150 1702 2 0% 0 0 0
mail (click) 916891 660410 374 5512 17 0% 0 0 0
psych-load (click) 346843 262980 68 480 1 0% 0 0 0
railsbench (click) 2651675 1964029 1436 9995 16 0% 0 0 0
binarytrees (click) 156187 115504 12 53 0 0% 0 0 0
chunky_png (click) 386843 289468 88 1009 0 0% 0 0 0
erubi (click) 322715 245814 10 79 0 0% 0 0 0
erubi_rails (click) 1961691 1429120 300 2032 4 0% 0 0 0
fannkuchredux (click) 170139 125272 9 191 0 0% 0 0 0
lee (click) 384795 290391 58 632 0 0% 0 0 0
nbody (click) 166811 124699 11 166 0 0% 0 0 0
optcarrot (click) 486363 420863 206 3583 20 0% 0 0 0
rubykon (click) 305691 244594 143 1572 1 0% 0 0 0
30k_ifelse (click) 5533403 4326969 9264 57799 0 0% 0 0 0
30k_methods (click) 2148571 1635431 5783 19356 0 0% 0 0 0
cfunc_itself (click) 154715 114277 9 44 0 0% 0 0 0
fib (click) 153179 113885 9 33 0 0% 0 0 0
getivar (click) 154907 115972 9 60 0 0% 0 0 0
keyword_args (click) 143707 105915 10 46 0 0% 0 0 0
respond_to (click) 144987 106728 9 59 0 0% 0 0 0
setivar (click) 154587 114507 9 33 0 0% 0 0 0
str_concat (click) 154843 115124 11 57 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.