YJIT Benchmarks

2022-08-09 20:13:57

As of 2022-08-09 20:13:57:

Overall YJIT is 36.1% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 34.7% 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 152.2 0.48% 153.6 0.64% 103.1 0.59% 0.99x 0.80% 1.48x 0.75% 85.93%
hexapdf 3213.4 1.05% 2359.1 1.73% 1.36x 2.02% 82.54%
liquid-render 196.7 0.95% 169.5 1.65% 127.0 1.78% 1.16x 1.90% 1.55x 2.02% 85.90%
mail 177.7 0.14% 175.1 2.46% 155.0 0.22% 1.01x 2.47% 1.15x 0.26% 99.37%
psych-load 2527.9 0.05% 2201.6 0.03% 1913.9 0.03% 1.15x 0.06% 1.32x 0.06% 88.89%
railsbench 2815.6 0.48% 2819.3 0.73% 2090.0 0.76% 1.00x 0.88% 1.35x 0.90% 86.54%
binarytrees 476.1 0.53% 304.8 0.32% 367.2 0.04% 1.56x 0.62% 1.30x 0.54% 84.27%
chunky_png 975.8 0.04% 790.7 0.37% 645.9 0.06% 1.23x 0.38% 1.51x 0.07% 99.95%
erubi 369.2 0.59% 338.7 0.64% 323.9 0.68% 1.09x 0.87% 1.14x 0.90% 100.00%
erubi_rails 27.0 2.62% 27.5 2.40% 19.3 3.59% 0.98x 3.56% 1.40x 4.44% 86.40%
fannkuchredux 6982.7 0.41% 3963.6 0.08% 7013.3 0.20% 1.76x 0.42% 1.00x 0.46% 0.02%
lee 1275.0 0.21% 1034.1 0.70% 932.2 0.68% 1.23x 0.73% 1.37x 0.71% 99.97%
nbody 127.6 0.29% 76.4 0.24% 91.3 0.07% 1.67x 0.37% 1.40x 0.30% 100.00%
optcarrot 6278.7 0.43% 2763.3 0.62% 3486.8 0.62% 2.27x 0.75% 1.80x 0.75% 96.16%
rubykon 12410.0 0.36% 8116.6 0.68% 6776.3 0.57% 1.53x 0.77% 1.83x 0.67% 99.69%
30k_ifelse 2351.8 0.01% 3508.6 3.95% 361.7 0.08% 0.67x 3.95% 6.50x 0.08% 100.00%
30k_methods 6330.4 0.03% 9995.3 18.09% 874.8 0.04% 0.63x 18.09% 7.24x 0.05% 100.00%
cfunc_itself 111.3 0.13% 68.5 0.30% 47.1 0.80% 1.63x 0.33% 2.37x 0.81% 100.00%
fib 264.6 0.12% 86.2 0.20% 63.4 0.07% 3.07x 0.24% 4.17x 0.14% 100.00%
getivar 105.8 0.49% 32.7 56.78% 44.2 0.12% 3.24x 56.78% 2.39x 0.50% 99.02%
keyword_args 295.6 0.09% 228.2 2.30% 52.6 0.33% 1.30x 2.31% 5.62x 0.34% 100.00%
respond_to 272.7 0.05% 225.2 0.36% 188.8 0.11% 1.21x 0.37% 1.44x 0.12% 100.00%
setivar 76.8 0.22% 20.9 63.10% 49.7 0.11% 3.67x 63.10% 1.54x 0.24% 99.14%
str_concat 83.6 1.09% 49.9 1.83% 43.3 1.66% 1.68x 2.13% 1.93x 1.98% 99.97%

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-09T11:11:48Z master ff07e5c264) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-08-09T11:11:48Z master ff07e5c264) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 65 65 76
hexapdf 307 402
liquid-render 31 35 37
mail 49 53 56
psych-load 37 45 40
railsbench 104 104 131
binarytrees 31 33 32
chunky_png 44 50 49
erubi 73 101 96
erubi_rails 102 103 122
fannkuchredux 25 27 27
lee 32 42 39
nbody 24 26 27
optcarrot 59 67 65
rubykon 53 60 57
30k_ifelse 68 169 127
30k_methods 57 176 75
cfunc_itself 25 27 27
fib 24 27 27
getivar 25 27 27
keyword_args 25 27 27
respond_to 24 27 27
setivar 25 26 27
str_concat 108 111 116

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 193 75 193 20 193
hexapdf 5 15 20 15
liquid-render 5 158 75 158 20 158
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 31 75 31 20 31
erubi 5 61 75 61 20 61
erubi_rails 5 1039 75 1039 20 1039
fannkuchredux 5 15 75 15 20 15
lee 5 21 75 21 20 21
nbody 5 261 75 261 20 261
optcarrot 5 15 75 15 20 15
rubykon 5 15 36 15 20 15
30k_ifelse 5 56 75 56 20 56
30k_methods 5 23 29 23 20 23
cfunc_itself 5 440 75 440 20 440
fib 5 315 75 315 20 315
getivar 5 610 75 610 20 610
keyword_args 5 376 75 376 20 376
respond_to 5 107 75 107 20 107
setivar 5 958 75 958 20 958
str_concat 5 467 75 467 20 467

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) 1035419 778966 131 1264 0 0% 0 0 0
hexapdf (click) 1150875 924351 683 8020 9 0% 0 0 0
liquid-render (click) 518939 403696 150 1676 2 0% 0 0 0
mail (click) 942299 678099 374 5770 17 0% 0 0 0
psych-load (click) 347035 263080 68 480 1 0% 0 0 0
railsbench (click) 2656475 1966549 1436 10017 16 0% 0 0 0
binarytrees (click) 171419 127952 13 58 0 0% 0 0 0
chunky_png (click) 385499 288668 88 997 0 0% 0 0 0
erubi (click) 322843 245914 10 79 0 0% 0 0 0
erubi_rails (click) 1964443 1431311 300 2047 4 0% 0 0 0
fannkuchredux (click) 185243 138082 10 188 0 0% 0 0 0
lee (click) 385115 290734 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) 320923 256912 144 1572 1 0% 0 0 0
30k_ifelse (click) 5560923 4348716 9265 57804 0 0% 0 0 0
30k_methods (click) 2176091 1657178 5784 19361 0 0% 0 0 0
cfunc_itself (click) 170395 127021 10 49 0 0% 0 0 0
fib (click) 168859 126629 10 38 0 0% 0 0 0
getivar (click) 170139 128420 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) 170523 127536 10 38 0 0% 0 0 0
str_concat (click) 170075 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.