12 comments

[ 2.9 ms ] story [ 57.7 ms ] thread
can we predict that jruby+truffle, will be usable for ruby gems in the next few years?
No, no we can't.

Or at least, I doubt it. You're free to predict whatever you like.

At the very least, I don't think any amb implementations are making their way to jruby any time soon. Although that's not an issue with any real-world code.

What's amb?
amb is a nondeterministic operator. It's a fun toy, although not terribly practical. It's usually implemented in terms of call/cc, a rare (and, as commonly implemented, expensive) function. CRuby implements it, JRuby doesn't.

It's not revelant to my main point, but I thought I'd have a bit of fun.

Actually, JRuby+Truffle can already install gems using Bundler, although it uses some hacks to work around issues like currently-missing OpenSSL.

Realistic Rails apps will not work yet, but there is fast progress in this area, we started this year with a minimal webserver and now got a simple blog app working with a PostgreSQL adapter.

How does truffle enhance JRuby to create such a dramatic performance improvement?
Truffle uses Graal, a new JIT compiler for the JVM written in Java. As it's written in Java, it can be used like a library - directly calling methods to compile exactly what you want, exactly how you want. Truffle uses this to compile your Ruby program using partial evaluation, a technique which is really good at removing the kind of overhead that the JVM usually adds, like costs for allocation.

This blog post and video explain where a lot of the big speedups come from.

http://chrisseaton.com/rubytruffle/deoptimizing/

I wrote my PhD about this topic, so there is even a whole thesis if you really want to get the details on how it works.

http://chrisseaton.com/phd/

(comment deleted)
I was intrigued by the method of piping pixel values to MPlayer as a frontend. I'll definitely be using that in future projects.

It makes use of this video format, which seems almost like a video equivalent of the PNM image format: https://wiki.multimedia.cx/index.php?title=YUV4MPEG2

I wish there was something similar that used RGB though.

While it's interesting how you can accelerate Ruby, 150 fps is still _awful_ for a NES emulator on modern platforms.

It kinda shows how bad Ruby's performance is compared to most other languages.

On the other hand, I am confident it's written in a much nicer way than most NES emulators (look at cpu.rb/ppu.rb).

The goal of optcarrot is explicitly not to be the "practical"or "the fastest NES emulator".

From https://github.com/mame/optcarrot > NOTE: We do not aim to create a practical NES emulator. There have been already many great emulators available. We recommend you use another emulator if you just want to play a game.

JRuby+Truffle's performance is not bad compared to other languages: https://github.com/smarr/are-we-fast-yet#current-status