YJIT Benchmarks

2022-08-10 20:16:41

As of 2022-08-10 20:16:41:

Overall YJIT is 35.6% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 36.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 154.4 0.37% 156.9 0.34% 103.8 0.64% 0.98x 0.50% 1.49x 0.74% 85.96%
hexapdf 3173.4 0.88% 2361.8 2.21% 1.34x 2.38% 83.00%
liquid-render 196.0 1.01% 168.9 1.68% 126.4 2.01% 1.16x 1.96% 1.55x 2.25% 85.90%
mail 176.5 0.15% 173.0 1.65% 154.9 0.18% 1.02x 1.66% 1.14x 0.23% 99.34%
psych-load 2439.0 0.10% 2143.6 0.02% 1893.9 0.02% 1.14x 0.11% 1.29x 0.10% 88.89%
railsbench 2849.2 0.40% 2787.5 0.50% 2088.3 0.88% 1.02x 0.65% 1.36x 0.97% 86.54%
binarytrees 466.4 0.08% 311.7 0.33% 380.1 1.31% 1.50x 0.34% 1.23x 1.31% 84.27%
chunky_png 1002.3 1.23% 780.3 0.39% 648.2 0.12% 1.28x 1.29% 1.55x 1.23% 99.95%
erubi 369.5 0.54% 341.0 0.64% 317.6 0.64% 1.08x 0.84% 1.16x 0.84% 100.00%
erubi_rails 26.9 2.58% 27.6 2.90% 19.4 3.81% 0.98x 3.88% 1.39x 4.60% 86.40%
fannkuchredux 5270.6 0.32% 2482.6 0.23% 2374.7 2.60% 2.12x 0.39% 2.22x 2.62% 77.42%
lee 1292.2 1.31% 1054.1 0.27% 981.7 2.11% 1.23x 1.34% 1.32x 2.48% 99.97%
nbody 137.5 0.11% 76.0 0.26% 94.7 0.11% 1.81x 0.28% 1.45x 0.16% 100.00%
optcarrot 6219.8 0.43% 2783.5 0.62% 3571.0 0.57% 2.23x 0.75% 1.74x 0.71% 96.16%
rubykon 12583.0 0.38% 8378.8 0.54% 6925.6 0.82% 1.50x 0.66% 1.82x 0.91% 99.62%
30k_ifelse 2395.4 0.04% 3946.6 4.09% 361.9 0.11% 0.61x 4.09% 6.62x 0.12% 100.00%
30k_methods 6277.0 0.06% 9870.5 18.22% 873.1 0.02% 0.64x 18.22% 7.19x 0.06% 100.00%
cfunc_itself 107.5 0.24% 70.6 0.26% 46.6 0.65% 1.52x 0.35% 2.31x 0.69% 100.00%
fib 238.8 0.07% 86.2 0.22% 63.4 0.15% 2.77x 0.23% 3.77x 0.17% 100.00%
getivar 108.8 0.83% 32.5 54.69% 44.2 0.12% 3.35x 54.69% 2.46x 0.84% 99.03%
keyword_args 297.2 0.15% 224.9 0.32% 54.9 0.21% 1.32x 0.35% 5.41x 0.25% 100.00%
respond_to 269.3 0.77% 244.9 0.51% 181.3 0.55% 1.10x 0.93% 1.48x 0.94% 100.00%
setivar 83.5 0.33% 20.2 61.59% 49.7 0.10% 4.13x 61.59% 1.68x 0.34% 99.14%
str_concat 83.5 1.13% 53.7 1.30% 45.7 1.52% 1.55x 1.73% 1.83x 1.90% 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-10T20:02:52Z master ff42e2359b) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-08-10T20:02:52Z master ff42e2359b) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 65 65 76
hexapdf 329 387
liquid-render 30 35 37
mail 49 53 56
psych-load 34 45 39
railsbench 104 106 133
binarytrees 28 33 30
chunky_png 41 50 49
erubi 80 103 95
erubi_rails 102 108 122
fannkuchredux 24 27 27
lee 33 41 41
nbody 24 26 27
optcarrot 63 70 69
rubykon 52 59 57
30k_ifelse 66 177 122
30k_methods 58 180 79
cfunc_itself 24 27 27
fib 24 26 26
getivar 24 26 27
keyword_args 24 27 26
respond_to 24 27 26
setivar 24 26 27
str_concat 114 115 121

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 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 31 75 31 20 31
erubi 5 62 75 62 20 62
erubi_rails 5 1037 75 1037 20 1037
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 56 75 56 20 56
30k_methods 5 22 30 22 20 22
cfunc_itself 5 443 75 443 20 443
fib 5 315 75 315 20 315
getivar 5 616 75 616 20 616
keyword_args 5 379 75 379 20 379
respond_to 5 106 75 106 20 106
setivar 5 958 75 958 20 958
str_concat 5 465 75 465 20 465

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) 1037467 780497 131 1293 0 0% 0 0 0
hexapdf (click) 1150811 924478 683 8020 9 0% 0 0 0
liquid-render (click) 521819 406486 150 1709 2 0% 0 0 0
mail (click) 914075 659522 374 5446 17 0% 0 0 0
psych-load (click) 347355 263298 68 482 1 0% 0 0 0
railsbench (click) 2656539 1966982 1436 10038 16 0% 0 0 0
binarytrees (click) 171675 127963 13 58 0 0% 0 0 0
chunky_png (click) 388123 290347 88 1014 0 0% 0 0 0
erubi (click) 322587 245629 10 79 0 0% 0 0 0
erubi_rails (click) 1961435 1428477 300 2026 4 0% 0 0 0
fannkuchredux (click) 186139 138394 10 196 0 0% 0 0 0
lee (click) 386395 291993 58 632 0 0% 0 0 0
nbody (click) 182811 137821 12 171 0 0% 0 0 0
optcarrot (click) 513755 442692 207 3588 20 0% 0 0 0
rubykon (click) 320923 257245 144 1569 1 0% 0 0 0
30k_ifelse (click) 5561243 4349094 9265 57804 0 0% 0 0 0
30k_methods (click) 2176411 1657556 5784 19361 0 0% 0 0 0
cfunc_itself (click) 170715 127399 10 49 0 0% 0 0 0
fib (click) 169179 127007 10 38 0 0% 0 0 0
getivar (click) 170907 129094 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) 170395 127618 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.