Many folks still seem to be in the dark about JRuby performance relative
to Ruby 1.8.x. I figured a short post with some basic info could start a
discussion for anyone wanting to know more.
Long story short, JRuby 1.1 is now generally faster than Ruby 1.8.6, and
for most execution benchmarks it is the fastest 1.8-compatible Ruby
implementation available. This is based on the YARV benchmarks, the
Alioth benchmarks, a number of benchmarks we created for JRuby, and a
few other external benchmarks we run from time to time. Many (most?) of
these are microbenchmarks, but a number are nontrivial code.
For example, M. Ed. Borasky’s MatrixBenchmark:
JRuby:
Hilbert matrix of dimension 64 times its inverse = identity? true
18.784000 0.000000 18.784000 ( 18.784000)
Ruby 1.8.6:
Hilbert matrix of dimension 64 times its inverse = identity? true
32.560000 0.110000 32.670000 ( 32.776915)
Or the YARV “pentomino” benchmark:
~/NetBeansProjects/jruby $ time jruby -J-server
test/bench/yarv/bm_app_pentomino.rb
real 1m31.770s
user 1m32.016s
sys 0m1.278s
~/NetBeansProjects/jruby $ time ruby test/bench/yarv/bm_app_pentomino.rb
real 1m48.100s
user 1m47.489s
sys 0m0.287s
Ola B. of the JRuby team recently ran all the YARV benchmarks and
reported the results here:
And I periodically post about performance progress on my blog here:
I expect we’ll see Alioth updated soon after the 1.1 or 1.1 beta 1
releases.
What about Rails?
One of the biggest uses for JRuby recently has been Rails. Rails
performance is a more complicated thing to measure; there’s a lot of
non-execution bottlenecks that get in the way. But both Ola and Nick
Sieger (also of JRuby team) have found that JRuby on Rails performance
is either very near or exceeding Ruby 1.8.x on Rails:
(toward the bottom of the post are updated Rails numbers)
http://blog.nicksieger.com/articles/2007/10/25/jruby-on-rails-fast-enough
Rails is probably the ultimate real-world benchmark, and we’re excited
to see that JRuby’s starting to pass Ruby 1.8.x performance here as
well.
I won’t drag this on any longer, but I’d encourage you to try out your
own Ruby code and let us know how it performs. We’ve spent a lot of time
on performance issues for the 1.1 release, and have many future plans to
continue increasing performance. We want your input.
Many people believed we’d never be faster than the C implementation, and
many still think we’re slower. Now that I’ve set that record straight,
any questions?
- Charlie