Ruby Forum JRuby > slow 'require' ?!

Posted by Andreas Hund (Guest)
on 09.05.2008 13:31
(Received via mailing list)
Hi,
I'm using JRuby 1.1.1 on Linux and performance after startup is very 
good.
But loading ruby libs by 'require' is very slow.
Sometimes I have to wait several seconds ...
-------------------------------------------
# TEST
def duration(&code)
  start_time = Time.now.to_f
  code.call
  Time.now.to_f - start_time
end

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??
Thanks

Andreas Hund

--
View this message in context: 
http://www.nabble.com/slow-%27require%27--%21-tp17146121p17146121.html
Sent from the JRuby - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
Posted by Thomas E Enebo (Guest)
on 10.05.2008 18:31
(Received via mailing list)
On Fri, May 9, 2008 at 6:31 AM, Andreas Hund <ahund@ionosinst.de> wrote:
>  Time.now.to_f - 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.

-Tom



--
Blog: http://www.bloglines.com/blog/ThomasEEnebo
Email: enebo@acm.org , tom.enebo@gmail.com

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email