Lionel Bouton wrote:
> I've briefly tried Jruby 1.0 and 1.1RC2 with the latest Sun 1.6 JVM on 
> Linux 32bit when we benchmarked the Ruby Quiz #157 submissions, but I 
> was not impressed (I didn't check the memory usage though):
> 
> - both threw a NulllException in the Jruby code when running one of the 
> submissions (you can easily reproduce this by looking for the benchmark 
> posts in the archives, there was an URL for a page with all the relevant 
> code), you just had to launch the benchmark to get it. There was no way 
> of protecting from this as it was out of Ruby's scope (ie a begin rescue 
> couldn't catch it),
> - 1.0 was slower than MRI (between 2x and 3x) and 1.1RC2 slightly faster 
> (5 to 10%), the code was mainly doing floating point computations.
> - Launching the JVM is 10x slower than MRI (unusable for small scripts 
> designed to return quickly).

There have been more perf improvements since RC2, but we should be more 
than 5-10% faster for normal computation. IO and such tend to drag us 
down a bit though, since there's necessarily more layers to go through.

> JRuby is still on my watch list (ruby-gettext is now pure Ruby so one of 
> my main obstacle to using it in production was recently removed) but I'm 
> not sure it is quite here yet (aborting the first program I try with it 
> with a NullException is not encouraging).

That's very unusual...most scripts run perfectly. If there's an NPE, it 
will be fixed by the end of today.

> For the small scripts problem with the JVM loading, at some point I've 
> read that future JVMs would have the ability of acting as resident 
> interpreters (ie: a JVM is always running in the background and new 
> instances are simply feeding it the code instead of loading a whole new 
> JVM). I didn't found any documentation on that in the java man page of 
> my local Sun 1.6.0.03 JDK install though :-(

JRuby supports running with Nailgun, a memory-resident background JVM. 
You need the source release to set it up, since it builds a small client 
app written in C. Unpack, "ant jruby-nailgun", and then you can use 
jruby-ng-server and jruby-ng to run scripts. There are a few caveats 
listed here, but it works pretty nice for quick hits:

http://wiki.jruby.org/wiki/JRuby_with_Nailgun

- Charlie