h1

Faster ruby(2)

July 20, 2007

Coming back to my previous post (and Charles’s comments!), I went and found my original test on those ruby constants.

picture-1.png

Here are the results on ruby (1.8.6):

  • WithConstants(N=5000000): 5.94s
  • WithoutConstants(N=5000000): 5.33s

Here are the results on jruby:

  • WithConstants(N=5000000): 34.15s
  • WithoutConstants(N=5000000): 27.47s

So my previous post was wrong, the same behavior appears on both ruby and jruby, and it looks like this is really worth the modification when running on jruby. Those are solely empiric results. I hope I can profile the jruby code and find the differences between the two tests and see from where comes the recorded time difference.

Updated:

Same tests again, with the options provided by Charles (-O -J-server -J-Djruby.jit.threshold=0):

  • WithConstants(N=5000000): 11.10s
  • WithoutConstants(N=5000000): 8.4s

Woah. That is really speeding things up!

2 comments

  1. FYI, there’s a few things you can do to speed this test up in JRuby:

    * Pass -J-server to JRuby to use the Java “server” VM

    * wrap the 0.upto pieces in methods and pass -J-Djruby.jit.threshold=0 to get them to compile (the whole script won’t compile because the compiler doesn’t compile class defs yet)

    * Pass -O to JRuby to turn off ObjectSpace

    With those changes made the two tests came in at around 9 seconds and 7 seconds, with MRI around 7.5 seconds on my sytsem.


  2. Charles,

    I’ve updated with my results with your options. It does really speed things up.
    Since I am trying to get an application to work seamlessly whether on ruby or jruby, I am going to try those options on our own test suite as well.
    Will keep you posted !

    Thanks a ton for that.



Leave a Comment