Slow 'require' ?!

I’m using JRuby 1.1.1 on Linux and performance after startup is very
But loading ruby libs by ‘require’ is very slow.
Sometimes I have to wait several seconds …


def duration(&code)
start_time = - start_time

dur = duration { require ‘pp’ }
puts “require pp: #{dur}”

dur = duration { require ‘yaml’ }
puts “require yaml: #{dur}”

dur = duration { require ‘rubygems’; require ‘log4r’ }
puts “require log4r: #{dur}”

JRuby 1.1.1

require pp: 0.303

require yaml: 0.800

require log4r: 0.677

Ruby 1.8.6

require pp: 0.015

require yaml: 0.030

require log4r: 0.058

Any suggestions or hints??

Andreas H.

View this message in context:'require'--!-tp17146121p17146121.html
Sent from the JRuby - User mailing list archive at

To unsubscribe from this list, please visit:

On Fri, May 9, 2008 at 6:31 AM, Andreas H. [email protected] wrote: - start_time

Any suggestions or hints??

On initial startup of JRuby many pieces of java code have not been
running long enough to get dynamic optimizations yet and requires
usually happen at the start of JRuby. Our parser is also quite a bit
slower than MRI. That may or may not explain the difference. You
could help try and isolate what is taking the most time, but that
requires digging into the Java code and perhaps using a profiler to
see what is going on.


Email: [email protected] , [email protected]

To unsubscribe from this list, please visit:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs