From: Charles Oliver Nutter Date: 2007-11-01T13:13:29+09:00 Subject: Re: JRuby perf questions answered Roger Pack wrote: >> any questions? > > Startup time and comparison with 1.9? :) Startup time varies widely between platforms. OS X is probably one of the fastest: ~/NetBeansProjects/jruby $ time ruby -e "puts 'hello'" hello real 0m0.015s user 0m0.007s sys 0m0.008s ~/NetBeansProjects/jruby $ time jruby -e "puts 'hello'" hello real 0m1.815s user 0m1.709s sys 0m0.183s There's been reports that on server-class machines the startup time can be as high as 5-10 seconds. The slow startup time is partially due to the JVM and partially our fault (JRuby's complicated, yo). As for Ruby 1.9...it's hard to make a comparison right now. Most of the benchmarks we use to measure Ruby 1.9 (like those I described previously) are usually a bit faster in Ruby 1.9. And of course almost all of Ruby 1.9's benchmarks are fastest in Ruby 1.9. Part of the difficulty comparing is that Ruby 1.9 contains a bunch of changes to Ruby language semantics that we have not yet put in JRuby, since we've focused on 1.8 compatibility. Things like: - fast math operations, that speed up +, -, etc, but you can't override them - constant-time case/when when literal values are used, but you can't override === for those literal types Here's A few numbers, for your edification. Some things are faster in Ruby 1.9: JRuby: ~/NetBeansProjects/jruby $ jruby -J-server test/bench/bench_fib_recursive.rb 0.869000 0.000000 0.869000 ( 0.869000) 0.677000 0.000000 0.677000 ( 0.677000) 0.652000 0.000000 0.652000 ( 0.652000) 0.648000 0.000000 0.648000 ( 0.648000) Ruby 1.9: ~/NetBeansProjects/jruby $ ../ruby1.9/ruby -I ../ruby1.9/lib test/bench/bench_fib_recursive.rb 0.400000 0.000000 0.400000 ( 0.405639) 0.400000 0.000000 0.400000 ( 0.406707) 0.400000 0.000000 0.400000 ( 0.400150) 0.400000 0.000000 0.400000 ( 0.398065) And some things are slower: JRuby: 1m loops yielding three fixnums 10 times to block splatting and accessing them 3.387000 0.000000 3.387000 ( 3.387000) 3.314000 0.000000 3.314000 ( 3.315000) 3.235000 0.000000 3.235000 ( 3.235000) Ruby 1.9: 1m loops yielding three fixnums 10 times to block splatting and accessing them 4.980000 0.020000 5.000000 ( 5.055369) 4.980000 0.020000 5.000000 ( 5.073821) 5.010000 0.020000 5.030000 ( 5.088681) And so on. However, for Rails, I've only seen one comparison that showed Ruby 1.9 was either slightly faster or slower than Ruby 1.8.x: http://eigenclass.org/hiki/non-synthetic-benchmarks-for-yarv I'm not sure if there's been a more recent comparison. I believe we'll be able to match Ruby 1.9 performance once we start making the same optimizations. - Charlie