YJIT Benchmarks

2022-09-19 20:11:41

As of 2022-09-19 20:11:41:

Overall YJIT is 36.9% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 32.9% 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 1.6 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 2.0 4.0 6.0 8.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 150.6 0.43% 176.2 4.06% 101.3 0.63% 0.85x 4.08% 1.49x 0.77% 85.99%
hexapdf 3193.1 1.09% 2307.9 1.93% 1.38x 2.21% 84.18%
liquid-render 195.0 0.99% 169.6 1.18% 117.1 1.88% 1.15x 1.54% 1.67x 2.12% 85.97%
mail 174.9 0.17% 174.9 2.48% 155.0 0.16% 1.00x 2.49% 1.13x 0.24% 99.37%
psych-load 2488.4 0.05% 2110.2 0.03% 1945.1 0.02% 1.18x 0.06% 1.28x 0.05% 88.89%
railsbench 2748.8 0.50% 3020.3 0.72% 2067.7 0.88% 0.91x 0.88% 1.33x 1.01% 86.57%
binarytrees 477.3 0.09% 316.5 0.04% 234.6 0.06% 1.51x 0.10% 2.03x 0.10% 100.00%
chunky_png 969.9 0.03% 785.8 0.16% 652.5 0.04% 1.23x 0.16% 1.49x 0.05% 99.95%
erubi 341.8 0.62% 315.2 3.43% 297.0 0.69% 1.08x 3.48% 1.15x 0.93% 100.00%
erubi_rails 26.1 2.57% 28.5 10.79% 19.0 3.60% 0.92x 11.09% 1.37x 4.43% 86.41%
fannkuchredux 5289.3 0.02% 5299.4 0.05% 2296.7 0.09% 1.00x 0.05% 2.30x 0.09% 77.42%
lee 1275.1 0.96% 1025.3 1.60% 957.6 0.36% 1.24x 1.87% 1.33x 1.03% 99.97%
nbody 121.6 0.09% 75.7 0.13% 92.2 0.07% 1.61x 0.16% 1.32x 0.12% 100.00%
optcarrot 6015.1 0.44% 2719.0 0.61% 3524.0 0.60% 2.21x 0.75% 1.71x 0.74% 96.16%
rubykon 12630.3 0.41% 8924.1 0.86% 6772.1 0.54% 1.42x 0.95% 1.87x 0.68% 99.76%
30k_ifelse 2325.9 0.01% 4353.3 2.95% 360.8 0.10% 0.53x 2.95% 6.45x 0.10% 100.00%
30k_methods 6279.7 0.01% 12763.5 4.31% 794.9 0.02% 0.49x 4.31% 7.90x 0.02% 100.00%
cfunc_itself 110.7 0.17% 98.8 0.12% 46.5 0.72% 1.12x 0.21% 2.38x 0.74% 100.00%
fib 240.5 0.09% 79.2 0.04% 62.7 0.04% 3.04x 0.10% 3.83x 0.10% 100.00%
getivar 104.4 0.12% 102.9 0.12% 42.7 0.05% 1.01x 0.17% 2.44x 0.13% 98.73%
keyword_args 290.2 0.07% 225.4 0.03% 55.6 0.17% 1.29x 0.08% 5.22x 0.18% 100.00%
respond_to 278.9 0.07% 259.1 0.12% 30.0 0.47% 1.08x 0.14% 9.30x 0.47% 100.00%
setivar 77.8 0.17% 77.8 0.17% 50.5 0.56% 1.00x 0.24% 1.54x 0.59% 98.00%
str_concat 83.5 0.86% 55.4 8.22% 47.6 1.42% 1.51x 8.27% 1.75x 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 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-09-19T15:44:30Z master 26135312f6) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-09-19T15:44:30Z master 26135312f6) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 65 71 76
hexapdf 293 411
liquid-render 30 33 37
mail 48 53 56
psych-load 35 42 43
railsbench 102 122 131
binarytrees 30 32 33
chunky_png 45 41 46
erubi 72 101 93
erubi_rails 101 107 122
fannkuchredux 24 26 27
lee 31 41 38
nbody 24 26 27
optcarrot 57 65 64
rubykon 50 60 55
30k_ifelse 68 142 128
30k_methods 58 164 79
cfunc_itself 24 26 27
fib 24 26 27
getivar 24 25 27
keyword_args 24 26 27
respond_to 25 26 27
setivar 24 26 27
str_concat 98 114 101

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 192 75 192 20 192
hexapdf 5 15 20 15
liquid-render 5 171 75 171 20 171
mail 5 128 75 128 20 128
psych-load 5 15 75 15 20 15
railsbench 5 15 75 15 20 15
binarytrees 5 84 75 84 20 84
chunky_png 5 30 75 30 20 30
erubi 5 67 75 67 20 67
erubi_rails 5 1048 75 1048 20 1048
fannkuchredux 5 15 56 15 20 15
lee 5 20 75 20 20 20
nbody 5 264 75 264 20 264
optcarrot 5 15 75 15 20 15
rubykon 5 15 31 15 20 15
30k_ifelse 5 55 68 55 20 55
30k_methods 5 25 23 25 20 25
cfunc_itself 5 429 75 429 20 429
fib 5 313 75 313 20 313
getivar 5 467 75 467 20 467
keyword_args 5 371 75 371 20 371
respond_to 5 668 75 668 20 668
setivar 5 400 75 400 20 400
str_concat 5 423 75 423 20 423

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) 1067319 777512 131 1279 0 0% 0 0 0
hexapdf (click) 1175927 917824 682 8036 9 0% 0 0 0
liquid-render (click) 530615 402250 150 1734 2 0% 0 0 0
mail (click) 964791 670226 374 5774 17 0% 0 0 0
psych-load (click) 356151 260910 68 480 1 0% 0 0 0
railsbench (click) 2734647 1964954 1436 10101 16 0% 0 0 0
binarytrees (click) 177143 127690 13 64 0 0% 0 0 0
chunky_png (click) 397751 287119 88 1028 0 0% 0 0 0
erubi (click) 339639 249148 10 79 0 0% 0 0 0
erubi_rails (click) 2022711 1428660 300 2029 4 0% 0 0 0
fannkuchredux (click) 189879 136594 10 196 0 0% 0 0 0
lee (click) 396407 288603 58 634 0 0% 0 0 0
nbody (click) 187319 136374 12 171 0 0% 0 0 0
optcarrot (click) 531703 441027 207 3592 20 0% 0 0 0
rubykon (click) 329847 255605 144 1580 1 0% 0 0 0
30k_ifelse (click) 5664247 4347294 9265 57804 0 0% 0 0 0
30k_methods (click) 2208823 1656109 5784 19361 0 0% 0 0 0
cfunc_itself (click) 174711 125952 10 49 0 0% 0 0 0
fib (click) 173047 125560 10 38 0 0% 0 0 0
getivar (click) 174519 127294 10 65 0 0% 0 0 0
keyword_args (click) 175095 126240 11 51 0 0% 0 0 0
respond_to (click) 174647 126813 10 64 0 0% 0 0 0
setivar (click) 174391 126064 10 38 0 0% 0 0 0
str_concat (click) 174263 126161 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.