The project became dormant as IMHO YJIT is moving into the right direction and competition with YJIT is not reasonable anymore. Please feel free to use any ideas and code if you need this.
Update May 2022: sir-mirjit-base and sir-mirjit branches were merged with May 2023 ruby trunk.
The branch sir-mirjit
is used for development of specialized VM insns (specialized IR or SIR in brief),
faster CRuby interpreter and MIR-based JIT (MIRJIT in brief) based on SIR
The last branch merge point with the trunk is always the head of the
branch sir-mirjit-base
sir-mirjit
will be merged with the trunk from
time to time and correspondingly the head of the branch
sir-mirjit-base
will be the last merge point with the trunksir_{plus,minus,mult,div,mod,or,and,eq,neq,lt,gt,le,ge,aref,aset}s{s,v,i}{s,v,i}
where suffix s
means value on stack, v
means local variable value, i
means immediate value.
Some suffix combinations (like vii
, sii
, sss
) are not permitted.
sir_i{plus,minus,mult,div,mod,or,and,eq,neq,lt,gt,le,ge,aref,aset}{s,v}{s,v,i}{s,v,i}
sir_f{plus,minus,mult,div,mod,eq,neq,lt,gt,le,ge}s{s,v,i}{s,v,i}
sir_ib{eq,neq,lt,gt,le,ge}{s,v,i}{s,v,i}
where i
after prefix sir_
means fixnum insns, and f
means flonum insns
sir_si{plus,minus,mult,div,mod,or,and,eq,neq,lt,gt,le,ge,aref,aset}s{s,v,i}{s,v,i}
sir_sf{plus,minus,mult,div,mod,eq,neq,lt,gt,le,ge}s{s,v,i}{s,v,i}
where i
after prefix sir_
means fixnum insns, and f
means flonum insns
sir_inspect_type
or sir_inspect_fixnum
)sir_iseq_send_without_block
or sir_cfunc_send
)sir_send_ivget
or sir_send_ivset
)sir_iter_{start,body,cont}
)sir_make_bbv
)
or jitting (e.g. sir_bbv_jit_call
).insns.def
sir_gen.c
sir_exec.c
and insns.def
mirjit.c
bbv
of MIR project (https://github.com/vnmakarov/mir
)sir-bench
bbv
branch with default install prefix (/usr/local
)
`bbv
is in development and therefore can be unstable.
Please use commit 0abe8498defc99f8a257588bd42b6e59f168cff7 which was used for benchmarking results below/usr/local
and want to build ruby w/o mirjit,
use option --without-mir
for ruby configure
cd sir-bench
taskset -cpu-list <a cpu-number> ruby compare.rb "<list ruby benchmarks from sir-bench>" base:../miniruby sir:'../miniruby --sir' yjit:'../miniruby --yjit' ...
taskset
as modern CPUs can have cores of different speedcd sir-bench
../miniruby [--sir|--yjit|...] -v -Ilib -r<path-to-optcarrot>/tools/shim <path-to-optcarrot>/bin/optcarrot --benchmark [--opt] -f=3000 <path-to-optcarrot>/examples/Lan_Master.nes
MIRJIT generates code for any frequently executed BBV while YJIT starts generation of BBVs of frequently executed method
MIRJIT generates C code which is translated into MIR-code and after that MIR is optimized and generated into machine code * YJIT generates machine code directly (although YJIT is moving to generating IR and then machine code)
red-black
, trees
, optcarrot
and some other benchmarksgenerated code -> SIR -> safe VM insn code
when the speculation assumptions
are not held. Switch to the safe VM insn code directly from the generated codec2m
sir_gen.c
allocates very large (mostly unused memory) for each Ruby methodAll measurements are done on Intel i5-13600K with 64GB memory under x86-64 Fedora Core36
I compared the following:
miniruby
)miniruby --sir
)miniruby --yjit
)miniruby --mirjit
)I used the following micro-benchmarks (see sir-bench directory):
Each benchmark ran 3 times and minimal time (or smallest maximum resident memory) was chosen
I also used optcarrot for more serious program performance comparison
Elapsed time: | base | sir | yjit | mir | |
---|---|---|---|---|---|
aread.rb | 1.0 | 3.74 | 7.21 | 8.78 | |
aref.rb | 1.0 | 3.76 | 5.06 | 9.24 | |
aset.rb | 1.0 | 3.41 | 3.12 | 8.91 | |
awrite.rb | 1.0 | 4.44 | 3.2 | 10.09 | |
bench.rb | 1.0 | 1.19 | 1.63 | 1.17 | |
call.rb | 1.0 | 2.1 | 4.82 | 4.87 | |
complex-mandelbrot.rb | 1.0 | 1.16 | 1.48 | 1.16 | |
const2.rb | 1.0 | 2.47 | 2.66 | 6.66 | |
const.rb | 1.0 | 2.46 | 2.66 | 6.7 | |
fannk.rb | 1.0 | 1.15 | 1.0 | 1.22 | |
fib.rb | 1.0 | 1.94 | 5.63 | 3.86 | |
ivread.rb | 1.0 | 2.19 | 6.22 | 3.54 | |
ivwrite.rb | 1.0 | 2.86 | 5.57 | 5.44 | |
mandelbrot.rb | 1.0 | 1.43 | 1.91 | 1.78 | |
meteor.rb | 1.0 | 1.29 | 1.35 | 1.25 | |
nbody.rb | 1.0 | 1.3 | 1.8 | 1.69 | |
nest-ntimes.rb | 1.0 | 2.06 | 1.3 | 1.96 | |
nest-while.rb | 1.0 | 3.53 | 0.99 | 10.24 | |
norm.rb | 1.0 | 1.67 | 2.13 | 2.2 | |
pent.rb | 1.0 | 1.11 | 1.31 | 0.9 | |
red-black.rb | 1.0 | 1.39 | 3.84 | 1.77 | |
sieve.rb | 1.0 | 2.41 | 1.25 | 3.15 | |
trees.rb | 1.0 | 1.38 | 2.23 | 1.48 | |
while.rb | 1.0 | 2.23 | 5.66 | 9.85 | |
GeoMean. | 1.0 | 2.0 | 2.55 | 3.28 |
base | sir | yjit | mir | |
---|---|---|---|---|
GeoMean. | 1.0 | 1.21 | 1.03 | 2.41 |
base | sir | yjit | mir | |
---|---|---|---|---|
optcarrot | 82.4 | 105.0 | 262.1 | 123.1 |
optcarrot --opt | 211.5 | 356.4 | 232.9 | 416.4 |