Skip to content

JRuby 9000 performance with --debug is 4-5x slower than JRuby 1.7.2 or Ruby 2.3.3 #4909

@nightsurge

Description

@nightsurge

JRuby 9k does not JIT when run in --debug and it runs quite a bit slower than 1.7.x.

Environment

*JRuby 9.1.13.0
*JRuby 1.7.2
*C/MRI Ruby 2.3.3
*MacOS 10.12.6
*JRUBY_OPTS=-J-Xmx2048m -J-Xmn512m --server --debug

Expected Behavior

Similar or better performance in JRuby 9000 as JRuby 1.7.2 / C|MRI Ruby 2.3.3

Actual Behavior

Performance is lower by a factor of 4-5x!

JRuby 9000

 Warming up --------------------------------------
        Instantiation   318.000  i/100ms
           Direct hit   354.000  i/100ms
         Class method   327.000  i/100ms
 Calculating -------------------------------------
        Instantiation      3.541k (± 3.5%) i/s -     35.616k in  10.071956s
           Direct hit      3.605k (± 2.6%) i/s -     36.108k in  10.021532s
         Class method      3.646k (± 3.5%) i/s -     36.624k in  10.058927s

 Comparison:
         Class method:     3646.1 i/s
           Direct hit:     3605.5 i/s - same-ish: difference falls within error
        Instantiation:     3540.7 i/s - same-ish: difference falls within error

JRuby 1.7.2

Warming up --------------------------------------
       Instantiation     1.119k i/100ms
          Direct hit     1.252k i/100ms
        Class method     1.335k i/100ms
Calculating -------------------------------------
       Instantiation     13.655k (± 4.8%) i/s -    136.518k
          Direct hit     13.610k (± 4.8%) i/s -    136.468k
        Class method     13.789k (± 4.1%) i/s -    138.840k

Comparison:
        Class method:    13789.3 i/s
       Instantiation:    13654.6 i/s - same-ish: difference falls within error
          Direct hit:    13610.2 i/s - same-ish: difference falls within error

Ruby 2.3.3

Warming up --------------------------------------
       Instantiation     1.542k i/100ms
          Direct hit     1.524k i/100ms
        Class method     1.536k i/100ms
Calculating -------------------------------------
       Instantiation     15.530k (± 4.7%) i/s -    155.742k in  10.051104s
          Direct hit     15.359k (± 5.4%) i/s -    153.924k in  10.051651s
        Class method     15.744k (± 3.8%) i/s -    158.208k in  10.064287s

Comparison:
        Class method:    15744.0 i/s
       Instantiation:    15530.4 i/s - same-ish: difference falls within error
          Direct hit:    15359.1 i/s - same-ish: difference falls within error

Very simple/generic test… JRuby 9000 is 4-5 times slower than JRuby 1.7.2/Ruby 2.3.3

Benchmark

require 'benchmark/ips'

class MyClass
  def self.call
    new.foo
  end

  def self.foo
    a = []
    1_000.times do |i|
      a << i
    end
    a
  end

  def foo
    a = []
    1_000.times do |i|
      a << i
    end
    a
  end
end

Benchmark.ips do |x|
  x.time = 10
  x.warmup = 3
  x.report("Instantiation") { MyClass.call }
  x.report("Direct hit") { MyClass.new.foo }
  x.report("Class method") { MyClass.foo }

  x.compare!
end

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions