A YARV to LLVM compiler

written by jedi on December 8th, 2008 @ 11:41 PM

YARV is the virtual machine shipped with Ruby 1.9. YARV is a great step forward, since current benchmarks show that Ruby 1.9 is about 4.5 times faster than Ruby 1.8. Speed wise, Ruby 1.9 can really compete PHP and Python. I also played with JRuby today, and its JIT and AOT compiler + a current JVM makes it a very scalable platform.

But here's a project that might really makes Ruby a speed daemon: a YARV to LLVM compiler.

The LLVM compiler infrastructure provides aggressive optimizations, and the recently-released Adobe Alchemy is yet another proof that LLVM rocks.

Can you imagine if Ruby code could be compiled through LLVM?

This is the goal of the yarv2llvm project and it already works pretty well. The web page is only in japanese, the benchmarks are easy to read:

http://d.hatena.ne.jp/miura1729/20081012/1223785541

42 times faster than Ruby 1.9. Pure crazyness. It probably blows away every VM of other script languages out there.

Here's the github for yarv2llvm, as you can see, the project is quite active.

(by there way, here's a link to a project that didn't get a lot of coverage, but that's also worth looking at: the Ludicrous JIT compiler although I'm quite confident that LLVM will remain more efficient).

Comments

  • Graham on 09 Dec 18:53

    All of this is just barking up the wrong tree. Ruby 1.9 is definitely a lot faster in microbenchmarks that don’t tax the garbage collector, but the moment real-world memory use patterns (at which point you spend 80% of CPU time in garbage collection) get into the picture it’s still as slow as 1.8.6. The switch to bytecode instead of putting effort into the actual pain-point of the ruby interpreter was nothing but premature and misguided optimization, and 1.9 is proof of that. I doubt this YARV->LLVM JITer will prove any different.

  • Hideki Miura on 10 Dec 10:09

    Thank you for introducing a yarv2llvm. Yarv2llvm accepts only subset of Ruby and the future will be so. Yarv2llvm treats data as static typed with type inference. So yarv2llvm is more strict than Ruby for type. I agree Graham’s opinion. Typical application by Ruby spends CPU time in library writing by C including GC. I don’t think using yarv2llvm for Web application. I think yarv2llvm for graphics or data mining. I am sorry for my poor English.

Comments are closed

Options:

Size

Colors