Project Shoehorn

Posted by Simes at 3:29 pm
Feb 222007

As many of you may know, I have something of a love/hate relationship with Lotus Domino. I love it for some of the things you can do with it, and I hate it for some of the hoops it makes you jump through when you try and do something slightly different. Also I hate LotusScript, but that’s only because I still hang on to a few shreds of my sanity. However, Domino is what I do for a living, so I’m kind of stuck with it.

Anyway. I’ve recently become interested in Ruby, and so set to wondering if it would be possible to in some way use Ruby’s elegant and succinct syntax in my neverending quest to be able to do the same amount of work only with less typing. Thus I came upon the notion of trying to run Ruby scripts from a Notes agent.

First of all, I needed it to even be possible. LotusScript isn’t going to let me do it, so I need to be able to run Ruby code from a Java agent. JRuby is a Ruby interpreter in Java, and BSF lets you embed instances of scripting interpreters, including JRuby, into Java code. So it’s possible.

Next I needed to work out which of Notes’ hoops to jump through to get code to run. In this case, you have to put the jar files in the JavaUserClasses notes.ini setting, because the AgentClassLoader apparently can’t load non-class resources from jar files and JRuby needs to be able to do this. Hoop successfully navigated.

Next you need to write and time some test code and compare it to Java code doing the same task. I wrote a simple loop which instantiates a Notes Document object and replaces the contents of a field 10,000 times. I included the instantiation of the BSF manager and the script interpreter instance in the time because in a real app, you’d have to do that anyway. Unfortunately this is where it all comes apart.

I was expecting the Ruby to be a little slower, but I wasn’t expecting it to be as slow as it turned out to be. I looped the test five times, and the results were:

Java code: Best case 110ms, worst case 321ms

JRuby code: Best case 8031ms, worst case 10925ms

The worst case Java was on the first pass through the loop, with the other passes all being close to the best case time. I attribute this to the JIT compilation in the VM. No such luck for the JRuby code, though, and it’s unfortunately so much slower that it’s not practical to take this experiment any further.

Still. Now I know. The test code is here for anyone who wants to check it out and suggest improvements. :)

4 Responses to “Project Shoehorn”

  1. Ruby is certainly slower than Java, this is true. But for most scenarios, JRuby is even slower than that at present. The situation has improved a lot in the past year…we’ve gone from an order of magnitude worse (or more) to perhaps 2-3x as slow as Ruby. But there are still big gains to be made. We have a compiler in progress that consistently runs faster than Ruby. We also have a number of performance improvements coming for interpreted mode that should bring us closer to Ruby’s speed. My recommendation would be to try again with JRuby trunk, rather than the 0.9.2 release (assuming that’s what you used) and to report your results on the JRuby mailing list too. If there’s a bottleneck, we should be able to find it, and both your project and our will benefit.

  2. Cool. I’ll grab the trunk build and check it out. Thanks!

  3. What version of domino are you testing this out on? 7?

  4. I’m testing it on my version 7 client.

Sorry, the comment form is closed at this time.

© 2011 simes dot org Suffusion theme by Sayontan Sinha