JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-6841

State file use in UUID gem causes severe performance degradation

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: JRuby 1.7.0.pre2
    • Fix Version/s: None
    • Labels:
      None
    • Number of attachments :
      0

      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)
      

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Charles Oliver Nutter
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated: