Issue Type: Bug Bug
Affects Versions: JRuby 1.7.0.pre2
Assignee: Unassigned
Components: Core Classes/Modules, Performance
Created: 14/Aug/12 9:11 AM
Description:

The 'uuid' gem uses a state file to maintain some global sequencing. However when using this file under JRuby, performance is severely impacted. It seems like the problem is its repeated reopening of the file for every UUID generated.

Benchmark:

require 'benchmark'
require 'uuid'

(ARGV[0] || 5).to_i.times do
  Benchmark.bm(20) do |bm|
    bm.report("default") do
      uuid = UUID.new
      100_000.times { uuid.generate }
    end
    bm.report("default, no state file") do
      old_state_file = UUID.state_file
      UUID.state_file = false
      uuid = UUID.new
      100_000.times { uuid.generate }
      UUID.state_file = old_state_file
    end
  end
end

Numbers:

system ~/projects/jruby/tmp/uuid $ jruby -Ilib bench_uuid.rb 
                           user     system      total        real
default               10.610000   3.870000  14.480000 (  9.157000)
default, no state file  1.390000   0.370000   1.760000 (  0.767000)
                           user     system      total        real
default                4.420000   3.660000   8.080000 (  6.886000)
default, no state file  0.370000   0.000000   0.370000 (  0.352000)
                           user     system      total        real
default                3.990000   3.610000   7.600000 (  6.723000)
default, no state file  0.400000   0.000000   0.400000 (  0.349000)
                           user     system      total        real
default                3.540000   3.550000   7.090000 (  6.580000)
default, no state file  0.380000   0.000000   0.380000 (  0.339000)
                           user     system      total        real
default                3.520000   3.510000   7.030000 (  6.551000)
default, no state file  0.350000   0.000000   0.350000 (  0.328000)

system ~/projects/jruby/tmp/uuid $ rvm 1.9.3 do ruby -Ilib bench_uuid.rb 
                           user     system      total        real
default                0.740000   0.010000   0.750000 (  0.736922)
default, no state file  0.730000   0.000000   0.740000 (  0.759890)
                           user     system      total        real
default                0.730000   0.000000   0.730000 (  0.734763)
default, no state file  0.730000   0.010000   0.740000 (  0.727520)
                           user     system      total        real
default                0.730000   0.000000   0.730000 (  0.734713)
default, no state file  0.760000   0.000000   0.760000 (  0.755858)
                           user     system      total        real
default                0.750000   0.000000   0.750000 (  0.759376)
default, no state file  0.730000   0.000000   0.730000 (  0.730918)
                           user     system      total        real
default                0.730000   0.010000   0.740000 (  0.730651)
default, no state file  0.730000   0.000000   0.730000 (  0.726645)
Fix Versions: JRuby 1.7.0.RC1
Project: JRuby
Priority: Major Major
Reporter: Charles Oliver Nutter
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira
--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

Reply via email to