JRuby startup costs [was: Process-level fork on OpenJDK...is it madness?]

Charles Oliver Nutter headius at headius.com
Tue Dec 13 16:51:56 PST 2011


On Tue, Dec 13, 2011 at 4:52 PM, Clemens Eisserer <linuxhippy at gmail.com> wrote:
> Hmm, from what I understand, hotspot's interpreter is already
> "super-hot" right after startup.
> Whereas JRuby's interpreter is jvm bytecode that needs to be compiled
> by a compiler, hotspot's interpreter is *hand-tuned* low-level
> assembly.

This is all true. The subtle part is that our interpreter runs faster
when jitted by the JVM than the JVM's interpreter can run compiled
Ruby code.

Here's "fib", first interpreted (by JRuby) but with the interpreter
jitted (by the JVM), and second compiled (by JRuby) but interpreted
(by the JVM):

system ~/projects/jruby $ jruby -X-C bench/bench_fib_recursive.rb 5 35
  3.179000   0.000000   3.179000 (  3.150000)
  3.650000   0.000000   3.650000 (  3.650000)
  3.739000   0.000000   3.739000 (  3.740000)
  3.733000   0.000000   3.733000 (  3.733000)
  3.778000   0.000000   3.778000 (  3.778000)

system ~/projects/jruby $ jruby -X+C -J-Xint bench/bench_fib_recursive.rb 5 35
 75.825000   0.000000  75.825000 ( 75.805000)
 75.994000   0.000000  75.994000 ( 75.994000)

Now this isn't *quite* fair since more than just the Ruby code is
running interpreted in the second case, but it illustrates a
point...our interpreter actually performs surprisingly well compared
to fully-interpreted Java, and as a result having Ruby code interpret
first often leads to things "warming up" more quickly (with the
alternative being to only ever run compiled Ruby code, but accept it
will be "cold" for 10000 calls).

- Charlie


More information about the mlvm-dev mailing list