Skip to content

Simple File IO is slower in JRuby 9.x than 1.7.x #4681

@alobmaier

Description

@alobmaier

When doing a simple benchmark for file IO (reading a big text file several times), I encountered a performance regression.

Used text file: test.txt

Benchmark code:

require 'benchmark'

Benchmark.bm do |x|
  5.times do 
    x.report do 
      1000.times do
        file = File.open('test.txt') 
        file.readlines
        file.seek 0
      end
    end
  end
end 

Environment

Running on Windows 10 (Version 1607).

Expected Behavior

I expected at least the same performance than JRuby 1.7.26.

Actual Behavior

JRuby 1.7.26:

C:\code> jruby -v .\io.rb
jruby 1.7.26 (1.9.3p551) 2016-08-26 69763b8 on Java HotSpot(TM) Client VM 1.8.0_111-b14 +jit [Windows 10-x86]
       user     system      total        real
   1.466000   0.000000   1.466000 (  1.466000)
   1.332000   0.000000   1.332000 (  1.331000)
   0.887000   0.000000   0.887000 (  0.887000)
   1.108000   0.000000   1.108000 (  1.108000)
   1.301000   0.000000   1.301000 (  1.301000)

JRuby 9.1.10.0:

C:\code> jruby -v .\io.rb
jruby 9.1.10.0 (2.3.3) 2017-05-25 b09c48a Java HotSpot(TM) Client VM 25.111-b14 on 1.8.0_111-b14 +jit [mswin32-x86]
       user     system      total        real
  19.523000   0.000000  19.523000 ( 19.522826)
  21.285000   0.000000  21.285000 ( 21.284657)
  20.799000   0.000000  20.799000 ( 20.799130)
  19.675000   0.000000  19.675000 ( 19.675062)
  19.823000   0.000000  19.823000 ( 19.823282)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions