I’ve been silent in this blog last few days, but that has an explanation: I’ve been trying to make JRuby 1.1.4 work with one of my scripts.
The problem is that after having done all the tweaks I can imagine, I still can’t get enough performance with Ruby 1.8.7 (latest etch-backports). Our client will not allow Ruby 1.9 in the server (what is really a pity, for the performance boost I had with Ruby 1.9 is awesome!), but it already have Java6… So the only option I have left is trying JRuby beast.
Since our script deals with system stuff, it uses syslog a lot, and that is where the main problem seems to be. Syslog support is new in JRuby, has had some implementation problems, and sure are not something to rely on right now… so I dropped it from the script, and it run! Twice as fast (not as good as Ruby 1.9, though)!
There are some other problems with this script and JRuby, more important ones being (1) at_exit doesn’t work; and (2) errors are not easy to backtrace (when JRuby fails it seems to mess up with the backtrace stack), but not preventing it to work…
So… with the increased performance of JRuby, and after fixing those minor glitches, I was still left with the syslog problem… Until I investigate some final solution (I think I’ll have to use some Java native syslog library – given such a thing exist), I’ve split the script in “performance-boost needing” and “syslog-needing” parts; the first is using JRuby, and the second, Ruby 1.8.7… They communicate using sockets (I know… ugly… I would like to use DRuby, but I would not introduce another point of failure in an already messy situation) and the overall performance was brought to a satisfactory level.
So far, it’s been interesting to study the issue… Mainly because I haven’t used JRuby since it’s early versions, and it has improved a lot. But also because I read a lot about the future of Ruby (bytecode compilation, YARV and so on), and it made me even happier with my primary-do-it-all programming language.
Now I’ll try to compile java bytecode generated by JRuby into a native binary with GCJ :-D. Let’s see if that is do-able…
Updated 2008-09-24 18:03:00: As you can see in the comments, syslog actually works. I figured this out this morning, but JRuby Subversion already had a patch. Anyway, I submitted another bug I found.