

RuJIT – Trace-based JIT Compiler for Ruby - ksec
https://github.com/imasahiro/rujit

======
ksec
From [http://brewhouse.io/blog/2014/09/19/ruby-
kaigi-2014-day-2](http://brewhouse.io/blog/2014/09/19/ruby-kaigi-2014-day-2)

RuJIT is a Trace-based JIT compiler, similar to the approach taken by
Firefox’s JS VM. It is based on the current version of CRuby, and resulted in
~2-5X speedup compared to trunk (and up to 100X in some cases).

Note: The Firefox JS VM in the article was referring to Tracemonkey. Mozilla
abandoned it and use Method JIT Compiler IonMonkey instead. A better Trace
Based JIT example would be LuaJIT.

~~~
amaranth
Doesn't Firefox use IonMonkey for general method JITing and TraceMonkey for
hotspots?

~~~
simonster
No. Firefox has an interpreter, a baseline method JIT ("Baseline"), and an
optimizing method JIT (IonMonkey). TraceMonkey was removed several years ago
after JaegerMonkey got type inference (see
[http://blog.mozilla.org/nnethercote/category/tracemonkey/](http://blog.mozilla.org/nnethercote/category/tracemonkey/)).

------
gsg
Looking at jit_codegen.c, seems it compiles a low-level IR to C, throws that
in a file and invokes cc on it (see cgen_freeze). Functions are pulled out
with dlsym.

Pretty heavy machinery for a JIT... but there's a comment about an LLVM
backend, so I suspect this is a temporary arrangement. It seems this project
is in its very early days.

------
alkonaut
Confusingly similar name to the new .NET JIT; "RyuJIT"!
[http://blogs.msdn.com/b/dotnet/archive/2013/09/30/ryujit-
the...](http://blogs.msdn.com/b/dotnet/archive/2013/09/30/ryujit-the-next-
generation-jit-compiler.aspx)

------
VeejayRampay
Whether we see the face of this in Ruby some day or not, I'm just really glad
people are putting effort and work into making Ruby faster. Whatever you can
do and say about the language, the fact remains that sometimes, the
productivity and expressivity you gain by using it is quite simply
overshadowed by the weight and sluggishness of the code it helps you produce.

------
RickHull
Interesting, but the github README looks like it was simply forked from Ruby
proper. Some more explanation would be nice before source-diving.

~~~
izietto
I think that from this commit

[https://github.com/imasahiro/rujit/commit/eb2e6cc5da47c212e8...](https://github.com/imasahiro/rujit/commit/eb2e6cc5da47c212e87608d1a518110cd0564a04)

To this one

[https://github.com/imasahiro/rujit/commit/c0e131bad4f0551425...](https://github.com/imasahiro/rujit/commit/c0e131bad4f0551425a44ca4f586bbfdde62ed3a)

resides the JIT implementation; it was better if it was a real fork of Ruby
Git, so one could compare Ruby master to RuJIT in order to look at the
changes.

~~~
dakull
Did anyone compile and benchmark it?

~~~
chrisseaton
I can't get it to compile on Mac or Linux but haven't dug into it yet.

------
izietto
I would have thought at this news as a big fat news on Ruby blogs, people who
dream to merge it into official MRI, +1000 points on HN... instead it seems to
be quite ignored; am I the only one interested in Ruby performances?

~~~
bri3d
It's 13 days old and entirely undocumented (at least in English). I think it's
probably a bit too early to say it's ignored.

I also think that a lot of the attention to Ruby performance has moved on from
CRuby (for better or for worse) and on to other implementations like Rubinius
and JRuby.

As for HN points, I think it's not sparking a lot of discussion yet because
it's difficult to understand. The approach and architectural specifics aren't
documented as far as I can tell and the code isn't forked / branched on GitHub
so effort is required to even figure out what code has changed at all.

I'd expect this project to get more popular once the talk describing it is
released and people have had a chance to look at it.

