YJIT Benchmarks

2022-08-05 20:14:04

As of 2022-08-05 20:14:04:

Overall YJIT is 37.7% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 37.1% 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 MJIT3.1 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 MJIT3.1 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 MJIT3.1 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 MJIT3.1 (ms) MJIT3.1 RSD YJIT (ms) YJIT RSD MJIT3.1 spd MJIT3.1 spd RSD YJIT spd YJIT spd RSD % in YJIT
activerecord 152.2 0.37% 155.8 0.30% 103.4 0.61% 0.98x 0.47% 1.47x 0.71% 85.93%
hexapdf 3201.7 0.83% 2373.1 2.36% 1.35x 2.50% 82.62%
liquid-render 197.9 0.95% 171.2 1.58% 125.9 1.72% 1.16x 1.84% 1.57x 1.97% 85.90%
mail 187.5 0.13% 175.9 2.35% 153.7 0.18% 1.07x 2.35% 1.22x 0.22% 99.34%
psych-load 2517.0 0.02% 2125.7 0.01% 1929.4 0.03% 1.18x 0.02% 1.30x 0.04% 88.89%
railsbench 2826.4 0.84% 2836.1 0.31% 2060.9 1.05% 1.00x 0.90% 1.37x 1.34% 86.38%
binarytrees 473.2 0.04% 305.0 0.31% 363.9 0.05% 1.55x 0.32% 1.30x 0.06% 84.27%
chunky_png 977.5 0.07% 774.3 0.04% 648.8 0.05% 1.26x 0.08% 1.51x 0.08% 99.95%
erubi 378.9 0.50% 345.5 0.68% 318.1 0.73% 1.10x 0.85% 1.19x 0.89% 100.00%
erubi_rails 27.2 3.14% 26.8 2.71% 19.4 3.56% 1.01x 4.15% 1.40x 4.75% 86.39%
fannkuchredux 6907.7 0.15% 3983.8 0.41% 7065.9 0.19% 1.73x 0.43% 0.98x 0.24% 0.02%
lee 1273.2 0.20% 1045.1 1.11% 933.4 1.19% 1.22x 1.13% 1.36x 1.20% 99.97%
nbody 129.0 0.78% 76.5 0.25% 90.6 0.06% 1.69x 0.82% 1.42x 0.78% 100.00%
optcarrot 6262.1 0.43% 2770.6 0.61% 3466.4 0.61% 2.26x 0.75% 1.81x 0.74% 96.16%
rubykon 12739.8 0.66% 8146.8 0.70% 6745.9 0.58% 1.56x 0.96% 1.89x 0.88% 99.66%
30k_ifelse 2284.3 0.01% 3583.5 3.79% 361.8 0.07% 0.64x 3.79% 6.31x 0.07% 100.00%
30k_methods 6385.9 0.03% 9994.1 17.97% 869.4 0.02% 0.64x 17.97% 7.35x 0.03% 100.00%
cfunc_itself 111.1 0.14% 69.6 0.60% 45.2 0.77% 1.60x 0.62% 2.46x 0.78% 100.00%
fib 258.3 0.17% 86.2 0.20% 63.5 0.08% 3.00x 0.26% 4.07x 0.19% 100.00%
getivar 105.8 0.44% 32.6 54.44% 44.2 0.05% 3.24x 54.45% 2.39x 0.44% 99.02%
keyword_args 287.5 0.09% 223.2 0.73% 52.4 0.22% 1.29x 0.74% 5.49x 0.23% 100.00%
respond_to 273.2 0.17% 225.3 0.56% 186.7 0.12% 1.21x 0.59% 1.46x 0.21% 100.00%
setivar 76.5 0.27% 20.9 63.39% 49.7 0.11% 3.66x 63.39% 1.54x 0.29% 99.14%
str_concat 83.6 0.98% 50.1 1.26% 43.2 1.55% 1.67x 1.60% 1.93x 1.83% 99.69%

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 it 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.
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-05T18:34:08Z master c433d36b5b) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-08-05T18:34:08Z master c433d36b5b) +MJIT [x86_64-linux]
(We got much better MJIT results with released than prerelease, so we used those.)

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT3.1 mem (MiB) YJIT mem (MiB)
activerecord 65 65 76
hexapdf 317 418
liquid-render 30 35 37
mail 49 53 56
psych-load 37 46 41
railsbench 104 106 132
binarytrees 31 33 33
chunky_png 44 47 48
erubi 73 101 88
erubi_rails 104 103 122
fannkuchredux 25 27 27
lee 32 40 39
nbody 25 26 27
optcarrot 58 67 65
rubykon 53 60 57
30k_ifelse 68 170 127
30k_methods 57 176 76
cfunc_itself 25 27 27
fib 24 27 26
getivar 25 27 27
keyword_args 25 27 27
respond_to 24 27 27
setivar 25 26 27
str_concat 122 110 107

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

By default, YJIT allocates an additional 256MiB for generated code. The additional size allocated can be tuned with a command-line parameter, but allocating too little memory will result in YJIT no longer JITting new functions, so performance reverts toward interpreter speeds.

Number of Iterations and Warmups Tested

bench No JIT warmups No JIT iters MJIT3.1 warmups MJIT3.1 iters YJIT warmups YJIT iters
activerecord 5 193 75 193 20 193
hexapdf 5 15 20 15
liquid-render 5 149 75 149 20 149
mail 5 129 75 129 20 129
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 65 75 65 20 65
chunky_png 5 30 75 30 20 30
erubi 5 62 75 62 20 62
erubi_rails 5 1030 75 1030 20 1030
fannkuchredux 5 15 75 15 20 15
lee 5 21 75 21 20 21
nbody 5 233 75 233 20 233
optcarrot 5 15 75 15 20 15
rubykon 5 15 37 15 20 15
30k_ifelse 5 55 75 55 20 55
30k_methods 5 22 29 22 20 22
cfunc_itself 5 438 75 438 20 438
fib 5 314 75 314 20 314
getivar 5 610 75 610 20 610
keyword_args 5 379 75 379 20 379
respond_to 5 106 75 106 20 106
setivar 5 960 75 960 20 960
str_concat 5 458 75 458 20 458

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) 1034331 778232 131 1276 0 0% 0 0 0
hexapdf (click) 1150875 924444 683 8021 10 0% 0 0 0
liquid-render (click) 522971 406902 150 1706 2 0% 0 0 0
mail (click) 906779 653611 374 5379 17 0% 0 0 0
psych-load (click) 347419 263298 68 482 1 0% 0 0 0
railsbench (click) 2653595 1965008 1436 10004 16 0% 0 0 0
binarytrees (click) 171931 128248 13 58 0 0% 0 0 0
chunky_png (click) 388827 290375 88 1026 0 0% 0 0 0
erubi (click) 323867 246820 10 79 0 0% 0 0 0
erubi_rails (click) 1960859 1428567 300 1997 4 0% 0 0 0
fannkuchredux (click) 185755 138378 10 188 0 0% 0 0 0
lee (click) 386203 291615 58 632 0 0% 0 0 0
nbody (click) 182299 137158 12 171 0 0% 0 0 0
optcarrot (click) 513499 442314 207 3588 20 0% 0 0 0
rubykon (click) 321691 257816 144 1580 2 0% 0 0 0
30k_ifelse (click) 5560987 4348716 9265 57804 0 0% 0 0 0
30k_methods (click) 2176155 1657178 5784 19361 0 0% 0 0 0
cfunc_itself (click) 170011 126725 10 49 0 0% 0 0 0
fib (click) 168475 126333 10 38 0 0% 0 0 0
getivar (click) 170651 128716 10 65 0 0% 0 0 0
keyword_args (click) 171291 127662 11 51 0 0% 0 0 0
respond_to (click) 172571 128475 10 64 0 0% 0 0 0
setivar (click) 170587 127536 10 38 0 0% 0 0 0
str_concat (click) 170139 127572 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.