YJIT Benchmarks

2022-08-02 20:16:57

As of 2022-08-02 20:16:57:

Overall YJIT is 34.9% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 34.6% 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.8 0.47% 154.6 0.31% 106.3 0.67% 0.99x 0.56% 1.44x 0.81% 85.94%
hexapdf 3109.8 1.02% 2256.4 2.27% 1.38x 2.49% 82.26%
liquid-render 194.6 0.98% 169.2 1.56% 124.9 1.48% 1.15x 1.84% 1.56x 1.78% 85.90%
mail 177.6 0.45% 174.3 1.84% 155.4 0.12% 1.02x 1.90% 1.14x 0.46% 99.34%
psych-load 2486.5 0.05% 2141.7 0.03% 1959.6 0.03% 1.16x 0.06% 1.27x 0.06% 88.89%
railsbench 2806.6 0.50% 2816.4 0.61% 2085.0 1.59% 1.00x 0.79% 1.35x 1.67% 86.54%
binarytrees 466.5 0.06% 309.1 0.32% 363.9 0.06% 1.51x 0.32% 1.28x 0.09% 84.27%
chunky_png 947.3 0.81% 778.1 0.05% 631.4 0.05% 1.22x 0.81% 1.50x 0.81% 99.95%
erubi 373.6 0.68% 338.7 0.66% 327.2 0.68% 1.10x 0.95% 1.14x 0.96% 100.00%
erubi_rails 27.2 2.64% 27.1 2.41% 19.2 3.46% 1.00x 3.57% 1.41x 4.35% 86.40%
fannkuchredux 7286.6 0.07% 3966.5 0.04% 6849.9 0.04% 1.84x 0.08% 1.06x 0.08% 0.02%
lee 1266.0 0.20% 1051.1 0.32% 948.3 1.13% 1.20x 0.38% 1.34x 1.15% 99.97%
nbody 125.5 0.12% 76.5 0.23% 97.5 0.08% 1.64x 0.26% 1.29x 0.15% 100.00%
optcarrot 6215.3 0.44% 2778.5 0.63% 3439.1 0.60% 2.24x 0.77% 1.81x 0.74% 96.16%
rubykon 12623.4 0.60% 8138.0 0.48% 6801.3 0.50% 1.55x 0.77% 1.86x 0.78% 99.84%
30k_ifelse 2236.4 0.02% 3640.3 7.90% 355.6 0.08% 0.61x 7.90% 6.29x 0.08% 100.00%
30k_methods 6267.8 0.01% 9873.6 20.14% 870.7 0.02% 0.63x 20.14% 7.20x 0.02% 100.00%
cfunc_itself 110.3 0.19% 68.1 0.97% 47.7 0.69% 1.62x 0.99% 2.31x 0.72% 100.00%
fib 254.3 0.05% 86.2 0.22% 63.3 0.05% 2.95x 0.23% 4.02x 0.07% 100.00%
getivar 112.1 0.18% 32.6 58.29% 44.2 0.05% 3.44x 58.29% 2.54x 0.19% 99.02%
keyword_args 284.1 0.09% 225.2 0.42% 52.7 0.22% 1.26x 0.43% 5.39x 0.24% 100.00%
respond_to 277.3 0.15% 237.4 0.32% 194.9 0.19% 1.17x 0.36% 1.42x 0.25% 100.00%
setivar 76.6 0.41% 20.9 63.05% 40.5 0.46% 3.67x 63.05% 1.89x 0.61% 99.14%
str_concat 84.0 0.79% 51.6 1.23% 44.3 1.46% 1.63x 1.46% 1.90x 1.66% 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 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-02T17:28:12Z master d8ea3a20fa) +YJIT [x86_64-linux]
Tested Ruby version for Ruby 3.1 MJIT: ruby 3.2.0dev (2022-08-02T17:28:12Z master d8ea3a20fa) +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 64 65 76
hexapdf 301 384
liquid-render 31 35 37
mail 49 54 56
psych-load 37 45 41
railsbench 103 106 131
binarytrees 31 33 33
chunky_png 43 46 48
erubi 77 83 93
erubi_rails 102 103 123
fannkuchredux 25 27 27
lee 32 40 39
nbody 25 26 27
optcarrot 58 67 65
rubykon 53 60 57
30k_ifelse 68 168 127
30k_methods 57 176 75
cfunc_itself 25 27 27
fib 25 27 27
getivar 25 27 27
keyword_args 25 27 27
respond_to 25 27 27
setivar 25 26 27
str_concat 98 110 101

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 159 75 159 20 159
mail 5 127 75 127 20 127
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 62 75 62 20 62
erubi_rails 5 1047 75 1047 20 1047
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 37 15 20 15
30k_ifelse 5 54 75 54 20 54
30k_methods 5 23 30 23 20 23
cfunc_itself 5 442 75 442 20 442
fib 5 315 75 315 20 315
getivar 5 612 75 612 20 612
keyword_args 5 370 75 370 20 370
respond_to 5 100 75 100 20 100
setivar 5 957 75 957 20 957
str_concat 5 453 75 453 20 453

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) 1039323 782130 131 1295 0 0% 0 0 0
hexapdf (click) 1151835 926061 683 8022 10 0% 0 0 0
liquid-render (click) 519387 403926 150 1670 2 0% 0 0 0
mail (click) 928923 669347 375 5607 17 0% 0 0 0
psych-load (click) 348059 263818 68 482 1 0% 0 0 0
railsbench (click) 2653851 1965192 1436 9991 16 0% 0 0 0
binarytrees (click) 172187 128374 13 58 0 0% 0 0 0
chunky_png (click) 387163 289944 88 998 0 0% 0 0 0
erubi (click) 323547 246784 10 79 0 0% 0 0 0
erubi_rails (click) 1961051 1429000 300 2006 4 0% 0 0 0
fannkuchredux (click) 186011 138504 10 188 0 0% 0 0 0
lee (click) 386779 292260 58 632 0 0% 0 0 0
nbody (click) 182811 137569 12 171 0 0% 0 0 0
optcarrot (click) 513755 442440 207 3588 20 0% 0 0 0
rubykon (click) 321179 256715 144 1570 1 0% 0 0 0
30k_ifelse (click) 5561243 4348842 9265 57804 0 0% 0 0 0
30k_methods (click) 2176411 1657304 5784 19361 0 0% 0 0 0
cfunc_itself (click) 170715 127147 10 49 0 0% 0 0 0
fib (click) 169179 126755 10 38 0 0% 0 0 0
getivar (click) 170907 128842 10 65 0 0% 0 0 0
keyword_args (click) 171099 127492 11 51 0 0% 0 0 0
respond_to (click) 172827 128601 10 64 0 0% 0 0 0
setivar (click) 170395 127366 10 38 0 0% 0 0 0
str_concat (click) 170523 127773 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.