YJIT Benchmarks

2022-08-13 20:13:48

As of 2022-08-13 20:13:48:

Overall YJIT is 34.8% 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 152.4 0.39% 153.8 0.43% 105.7 0.68% 0.99x 0.58% 1.44x 0.78% 85.96%
hexapdf 3189.4 1.10% 2377.7 2.77% 1.34x 2.98% 83.05%
liquid-render 196.5 0.99% 170.8 1.62% 125.6 1.80% 1.15x 1.90% 1.56x 2.05% 85.90%
mail 173.7 0.12% 173.2 1.54% 155.3 0.19% 1.00x 1.54% 1.12x 0.23% 99.34%
psych-load 2471.8 0.03% 2140.6 0.04% 1892.3 0.05% 1.15x 0.05% 1.31x 0.06% 88.89%
railsbench 2833.5 0.73% 2828.0 0.74% 2092.7 1.63% 1.00x 1.04% 1.35x 1.79% 86.38%
binarytrees 461.8 0.09% 326.9 1.88% 371.3 0.09% 1.41x 1.89% 1.24x 0.13% 84.27%
chunky_png 974.9 0.05% 780.0 0.14% 649.6 0.05% 1.25x 0.15% 1.50x 0.07% 99.95%
erubi 384.7 0.92% 343.9 0.63% 328.2 0.79% 1.12x 1.12% 1.17x 1.22% 100.00%
erubi_rails 27.1 2.57% 27.3 2.34% 19.3 3.55% 0.99x 3.48% 1.40x 4.38% 86.41%
fannkuchredux 5262.3 0.10% 2490.9 0.06% 2345.8 0.20% 2.11x 0.12% 2.24x 0.22% 77.42%
lee 1272.2 0.72% 1062.1 0.13% 967.5 0.08% 1.20x 0.73% 1.31x 0.72% 99.97%
nbody 138.0 0.30% 77.1 0.25% 95.1 0.08% 1.79x 0.39% 1.45x 0.31% 100.00%
optcarrot 6255.6 0.43% 2826.3 0.61% 3517.4 0.68% 2.21x 0.75% 1.78x 0.80% 96.16%
rubykon 12538.5 0.53% 8250.1 0.81% 6913.8 1.25% 1.52x 0.97% 1.81x 1.36% 99.61%
30k_ifelse 2425.7 0.01% 3738.2 3.32% 359.1 0.09% 0.65x 3.32% 6.75x 0.09% 100.00%
30k_methods 6296.3 0.18% 10289.1 15.75% 882.2 0.02% 0.61x 15.75% 7.14x 0.18% 100.00%
cfunc_itself 115.1 0.28% 70.2 0.92% 46.6 0.61% 1.64x 0.96% 2.47x 0.67% 100.00%
fib 234.1 0.08% 86.2 0.20% 63.4 0.08% 2.72x 0.22% 3.69x 0.11% 100.00%
getivar 106.9 0.64% 32.2 53.70% 44.2 0.12% 3.32x 53.70% 2.42x 0.65% 99.03%
keyword_args 282.7 0.12% 225.8 0.67% 54.2 0.13% 1.25x 0.68% 5.22x 0.17% 100.00%
respond_to 271.9 0.45% 224.6 1.27% 182.8 0.15% 1.21x 1.35% 1.49x 0.47% 100.00%
setivar 83.5 0.28% 20.2 61.62% 49.7 0.15% 4.13x 61.62% 1.68x 0.32% 99.17%
str_concat 83.4 1.10% 53.3 1.21% 44.9 1.27% 1.56x 1.63% 1.86x 1.68% 99.81%

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-13T02:23:47Z master 0617cba197) +YJIT [x86_64-linux]
Tested Ruby version for Ruby latest MJIT: ruby 3.2.0dev (2022-08-13T02:23:47Z master 0617cba197) +MJIT [x86_64-linux]

Benchmark Memory Usage Details

bench No JIT mem (MiB) MJIT mem (MiB) YJIT mem (MiB)
activerecord 65 65 77
hexapdf 270 391
liquid-render 30 35 37
mail 49 53 56
psych-load 36 45 41
railsbench 104 105 131
binarytrees 28 32 30
chunky_png 41 44 45
erubi 104 110 120
erubi_rails 102 103 122
fannkuchredux 24 27 26
lee 32 38 41
nbody 24 26 26
optcarrot 63 70 69
rubykon 53 58 56
30k_ifelse 66 166 122
30k_methods 59 180 79
cfunc_itself 24 27 27
fib 24 27 26
getivar 24 26 26
keyword_args 24 27 26
respond_to 24 27 26
setivar 24 26 26
str_concat 102 110 107

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 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 60 75 60 20 60
chunky_png 5 30 75 30 20 30
erubi 5 62 75 62 20 62
erubi_rails 5 1027 75 1027 20 1027
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 36 15 20 15
30k_ifelse 5 50 75 50 20 50
30k_methods 5 21 29 21 20 21
cfunc_itself 5 422 75 422 20 422
fib 5 315 75 315 20 315
getivar 5 618 75 618 20 618
keyword_args 5 367 75 367 20 367
respond_to 5 107 75 107 20 107
setivar 5 990 75 990 20 990
str_concat 5 445 75 445 20 445

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) 1035227 778792 131 1281 0 0% 0 0 0
hexapdf (click) 1151579 924912 683 8026 9 0% 0 0 0
liquid-render (click) 519195 403324 150 1671 2 0% 0 0 0
mail (click) 899355 648935 375 5327 17 0% 0 0 0
psych-load (click) 346715 262791 68 482 1 0% 0 0 0
railsbench (click) 2654939 1966404 1436 10013 16 0% 0 0 0
binarytrees (click) 171419 127952 13 58 0 0% 0 0 0
chunky_png (click) 392539 292598 88 1070 0 0% 0 0 0
erubi (click) 322459 245796 10 79 0 0% 0 0 0
erubi_rails (click) 1962715 1429387 300 2041 4 0% 0 0 0
fannkuchredux (click) 185819 138016 10 196 0 0% 0 0 0
lee (click) 384411 290124 58 632 0 0% 0 0 0
nbody (click) 182491 137443 12 171 0 0% 0 0 0
optcarrot (click) 513435 442314 207 3588 20 0% 0 0 0
rubykon (click) 320923 256854 144 1570 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.