YJIT Benchmarks

2022-08-15 05:26:58

As of 2022-08-15 05:26:58:

Overall YJIT is 35.2% faster than interpreted CRuby!
On Railsbench specifically, YJIT is 35.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.2 0.39% 158.8 0.34% 103.4 0.59% 0.97x 0.51% 1.49x 0.71% 85.96%
hexapdf 3204.1 0.95% 2388.7 2.34% 1.34x 2.53% 84.03%
liquid-render 197.1 2.22% 168.1 1.63% 128.5 1.73% 1.17x 2.75% 1.53x 2.81% 85.90%
mail 176.2 0.16% 172.9 1.65% 156.2 0.20% 1.02x 1.66% 1.13x 0.25% 99.35%
psych-load 2458.0 0.03% 2131.7 0.02% 1885.1 0.02% 1.15x 0.03% 1.30x 0.03% 88.89%
railsbench 2808.8 0.55% 2833.9 0.51% 2075.0 0.85% 0.99x 0.75% 1.35x 1.01% 86.54%
binarytrees 461.7 0.09% 332.0 1.50% 369.8 0.08% 1.39x 1.50% 1.25x 0.12% 84.27%
chunky_png 975.6 0.04% 784.9 0.41% 652.3 0.05% 1.24x 0.41% 1.50x 0.07% 99.95%
erubi 375.3 0.71% 343.4 0.63% 321.1 0.66% 1.09x 0.95% 1.17x 0.97% 100.00%
erubi_rails 27.3 2.61% 27.0 2.65% 19.5 3.64% 1.01x 3.71% 1.40x 4.47% 86.41%
fannkuchredux 5286.5 0.09% 2494.2 0.47% 2347.7 0.21% 2.12x 0.48% 2.25x 0.23% 77.42%
lee 1276.7 1.31% 1058.2 0.18% 967.6 0.07% 1.21x 1.32% 1.32x 1.31% 99.97%
nbody 139.0 0.10% 75.9 0.24% 94.7 0.10% 1.83x 0.26% 1.47x 0.14% 100.00%
optcarrot 6297.1 0.42% 2769.7 0.62% 3602.3 0.57% 2.27x 0.75% 1.75x 0.71% 96.16%
rubykon 12700.1 0.46% 8369.1 0.44% 6919.1 0.51% 1.52x 0.63% 1.84x 0.69% 99.61%
30k_ifelse 2355.9 0.07% 3756.6 3.99% 356.0 0.08% 0.63x 3.99% 6.62x 0.11% 100.00%
30k_methods 6478.9 0.03% 9850.9 19.42% 874.3 0.02% 0.66x 19.42% 7.41x 0.04% 100.00%
cfunc_itself 106.1 0.21% 70.4 0.31% 46.4 0.50% 1.51x 0.37% 2.29x 0.54% 100.00%
fib 235.4 0.15% 86.3 0.24% 63.4 0.08% 2.73x 0.28% 3.71x 0.17% 100.00%
getivar 106.8 0.64% 32.3 54.28% 44.3 0.12% 3.31x 54.28% 2.41x 0.65% 99.03%
keyword_args 285.1 0.11% 222.9 0.35% 54.6 0.12% 1.28x 0.36% 5.22x 0.16% 100.00%
respond_to 276.5 0.37% 225.4 0.44% 183.6 0.61% 1.23x 0.57% 1.51x 0.71% 100.00%
setivar 84.2 0.42% 20.2 61.05% 49.7 0.12% 4.18x 61.05% 1.69x 0.44% 99.17%
str_concat 83.8 1.11% 53.1 1.36% 44.8 1.73% 1.58x 1.75% 1.87x 2.05% 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-15T05:12:08Z master cbcf2dad39) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-08-15T05:12:08Z master cbcf2dad39) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 65 65 77
hexapdf 319 391
liquid-render 30 35 37
mail 49 53 56
psych-load 35 45 38
railsbench 104 106 133
binarytrees 28 32 30
chunky_png 41 47 45
erubi 102 120 96
erubi_rails 102 104 123
fannkuchredux 24 27 27
lee 32 39 41
nbody 24 26 26
optcarrot 63 69 68
rubykon 52 60 57
30k_ifelse 66 171 123
30k_methods 58 184 79
cfunc_itself 24 27 26
fib 24 26 26
getivar 24 26 26
keyword_args 24 27 27
respond_to 24 27 26
setivar 24 26 26
str_concat 102 112 109

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 195 75 195 20 195
hexapdf 5 15 20 15
liquid-render 5 156 75 156 20 156
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 27 75 27 20 27
erubi 5 61 75 61 20 61
erubi_rails 5 1038 75 1038 20 1038
fannkuchredux 5 15 75 15 20 15
lee 5 20 75 20 20 20
nbody 5 263 75 263 20 263
optcarrot 5 15 75 15 20 15
rubykon 5 15 35 15 20 15
30k_ifelse 5 56 75 56 20 56
30k_methods 5 22 29 22 20 22
cfunc_itself 5 430 75 430 20 430
fib 5 311 75 311 20 311
getivar 5 620 75 620 20 620
keyword_args 5 353 75 353 20 353
respond_to 5 105 75 105 20 105
setivar 5 991 75 991 20 991
str_concat 5 446 75 446 20 446

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) 1033627 777512 131 1267 0 0% 0 0 0
hexapdf (click) 1151899 925135 682 8038 9 0% 0 0 0
liquid-render (click) 516379 401527 150 1644 2 0% 0 0 0
mail (click) 899355 649112 374 5326 17 0% 0 0 0
psych-load (click) 347035 263080 68 480 1 0% 0 0 0
railsbench (click) 2652955 1964784 1436 10015 16 0% 0 0 0
binarytrees (click) 171867 128248 13 58 0 0% 0 0 0
chunky_png (click) 389019 290587 88 1030 0 0% 0 0 0
erubi (click) 322779 245889 10 79 0 0% 0 0 0
erubi_rails (click) 1961563 1428865 300 2034 4 0% 0 0 0
fannkuchredux (click) 185819 138016 10 196 0 0% 0 0 0
lee (click) 384987 290684 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) 320731 256834 144 1571 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) 170587 128716 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) 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.