From: Charles Oliver Nutter Date: 2008-05-13T12:26:48+09:00 Subject: Re: Huge performance gap Vidar Hokstad wrote: > On May 12, 7:54 am, Roger Pack wrote: >> Bill Kelly wrote: >>> But yes, it's harder to make a language like Ruby, which is highly >>> dynamic at runtime, fast like C++ and Java, which are primarily >>> statically compiled. The Smalltalk folks have reportedly done pretty >>> well though, so there exists the possiblilty that Ruby may get >>> substantially faster in the future. YARV is already making some >>> headway. >> My question is what does 1.9 exactly do with its "Inline (Method) >> cache"[1]? Is there room for more improvement with a better JIT >> compiler? How much would this help scripts? > > There's a huge amount of room for improvement in the still. I haven't > seen any of the Ruby implementations even try to apply more > sophisticated > VM/JIT techniques such as tracing and polymorphic inline caches > properly. I've experimented with PICs in JRuby, and for most tests I ran they did not help very much. Granted, there's an unfortunate lack of nontrivial polymorphic benchmarks in the wild, so it's possible a good PIC would help more on real apps. What does make a huge difference for JRuby is eliminating some of the extra overhead related to rarely-used Ruby features. For example, the difference between a normal run and a run that eliminates an unnecessary frame object, uses fast dispatch for math operations, and eliminates some thread checkpointing: ~/NetBeansProjects/jruby ➔ jruby -J-server test/bench/bench_fib_recursive.rb 0.746000 0.000000 0.746000 ( 0.746000) 0.371000 0.000000 0.371000 ( 0.370000) 0.357000 0.000000 0.357000 ( 0.357000) 0.357000 0.000000 0.357000 ( 0.357000) 0.358000 0.000000 0.358000 ( 0.357000) ~/NetBeansProjects/jruby ➔ jruby -J-server -J-Djruby.compile.fastest=true test/bench/bench_fib_recursive.rb 0.960000 0.000000 0.960000 ( 0.959000) 0.243000 0.000000 0.243000 ( 0.243000) 0.238000 0.000000 0.238000 ( 0.238000) 0.237000 0.000000 0.237000 ( 0.237000) 0.235000 0.000000 0.235000 ( 0.235000) And Ruby 1.9: ~/NetBeansProjects/jruby ➔ ../ruby1.9/ruby -I ../ruby1.9/lib test/bench/bench_fib_recursive.rb 0.400000 0.010000 0.410000 ( 0.412421) 0.400000 0.000000 0.400000 ( 0.407236) 0.400000 0.000000 0.400000 ( 0.415222) 0.400000 0.010000 0.410000 ( 0.417042) 0.400000 0.000000 0.400000 ( 0.452934) So yes, there's definitely room to improve all the implementations... - Charlie