Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

JRuby 1.1 Beta 1 Released; Faster Than The Regular Ruby Interpreter

By Peter Cooper / November 4, 2007

Thomas Enebo of the JRuby team has announced the release of the first beta of JRuby 1.1. This is a significant release, focusing heavily on performance increases. The performance increases yielded so far are so significant that in most like-for-like tests, JRuby beats the regular Ruby interpreter (a.k.a. MRI) JRuby 1.1. On Rails-focused tests, JRuby also wins.. making JRuby the fastest way to run Rails applications at present. Charles Nutter talks about the improvements, along with a number of other interesting JRuby-related topics, in his latest blog post - a must read for Ruby implementation nuts.

Comments

  1. SMERF says:

    I don't understand. I just did a quick and dirty test and MRI is twice as fast as JRuby 1.1b1 (MBP 2GB 2.16GHz osx 10.4.10 )

    MATZ - MRI
    =======


    irb(main):006:0> puts Benchmark.measure { pythag(5000) }
    20.980000 0.120000 21.100000 ( 22.582690)
    => nil
    irb(main):007:0> puts Benchmark.measure { pythag(5000) }
    20.620000 0.140000 20.760000 ( 24.144776)
    => nil

    JRUBY 1.2.1b1
    ========


    irb(main):003:0> puts Benchmark.measure { pythag(5000) }
    40.231000 0.000000 40.231000 ( 40.230000)
    => nil
    irb(main):004:0> puts Benchmark.measure { pythag(5000) }
    41.851000 0.000000 41.851000 ( 41.851000)
    => nil
    irb(main):005:0>

  2. SMERF says:

    def pythag(n)
    result = []
    (2..n).each do |c|
    (1...c).each do |b|
    a = Math.sqrt(c*c - b*b)
    result

  3. SMERF says:

    Sorry, the html sanitizer ate half of my comment.

    def pythag(n)
    result = []
    (2..n).each do |c|
    (1...c).each do |b|
    a = Math.sqrt(c*c - b*b)
    result << [a.to_i, b, c] if a.to_i == a
    end
    end
    result
    end

  4. Charles Oliver Nutter says:

    SMERF: Run JRuby with -J-server, which will use the faster "server" JVM....to do so in JIRB, run it like this:

    jruby -J-server -S irb

  5. Charles Oliver Nutter says:

    Also, I notice now that your pythag function is iterative, which means that it won't get JIT compiled until it's been called 20 times. Try running it at a command line. I did so with -J-server, with a script that benchmarks pythag(5000) twice and got the following results:

    ~/NetBeansProjects/jruby $ jruby -J-server test/bench/bench_pythag.rb
    18.050000 0.000000 18.050000 ( 18.049000)
    17.857000 0.000000 17.857000 ( 17.857000)
    ~/NetBeansProjects/jruby $ ruby test/bench/bench_pythag.rb
    21.180000 0.050000 21.230000 ( 21.258206)
    21.190000 0.050000 21.240000 ( 21.248542)

    This would be faster without blocks.

  6. Bummer Han says:

    my only question is if Ruby runs deterministically the same under jruby as with the dominant ruby interpreter, considering Ruby lang itself is not so well documented.

Other Posts to Enjoy

Twitter Mentions