Slow to load rubygems

I’ve noticed that (on a warm start),

$ time jruby -rubygems -e ‘’

real 0m2.607s
user 0m0.860s
sys 0m1.600s

$ time ruby187 -rubygems -e ‘’

real 0m0.119s
user 0m0.088s
sys 0m0.028s

Here is jruby’s “default” startup time

$ time jruby -e ‘’

real 0m1.038s
user 0m0.208s
sys 0m0.732s

Which is reasonable, however 1.5s to load rubygems on warm start seems
pretty odd compared to 0.1s for 187.

Also this code:

Benchmark.realtime { 10.times { require ‘rubygems’;
$LOADED_FEATURES.delete ‘rubygems.rb’ }}

takes 2.2s with jruby and 0.73s with 1.8.7 for me (in this instance, $:
is of size 4 for jruby, size 9 for 1.8.7, so that doesn’t explain the
difference).

Same for this line

Benchmark.realtime { 10.times { load
“/home/rdp/installs/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems.rb”
}}

Should this be considered a bug?

I hope so…

Thanks.
-rp

Same for this line

Benchmark.realtime { 10.times { load
“/home/rdp/installs/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems.rb”
}}

The slowdown might be in eval.

a = File.read
“/home/rdp/installs/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems.rb”

Benchmark.realtime { 10.times { eval a }}

This takes 1.8s in jruby, 0.64s in 1.8.7

-r

Hi Roger,

Slow(ish) rubygems startup is a well-known problem and we are
constantly looking for improving it.

See, for example:
http://blog.emptyway.com/2009/11/21/making-sense-out-of-slow-rubygems-startup/

Comparing JRuby 1.4.0 and JRuby 1.5.0.dev, we’ve made quite some
progress:

JRuby 1.4:
jruby -b -e “require ‘rubygems’”
Runtime: 1220 ms

JRuby 1.5:
jruby -b -e “require ‘rubygems’”
Runtime: 844 ms

Not that bad! :slight_smile:

We’ll continue to optimize and speed-up things, but it is a very hard
problem, JRuby’s parsing especially until the Java VM is warmed-up, is
not very fast, and RubyGems just does WAAY, WAAAAAY TOO MUCH during
startup. For MRI that’s not the huge problem, but even for MRI, I keep
hearing from time to time that rubygems is slow.

So, the best way improving things is to profile the rubygems and make
it do less things at startup. That would help out not only JRuby, but
Rubinius and MRI itself.

Thanks,
–Vladimir

On Mon, Feb 22, 2010 at 7:15 PM, Roger P. [email protected]
wrote:

real 0m0.119s

difference).


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Benchmark.realtime { 10.times { eval a }}

This takes 1.8s in jruby, 0.64s in 1.8.7

Looks like with jruby HEAD --server, it now takes 2.4s in jruby, still
0.64 in 1.8.7

Is this specific case (slow eval, even when warmed up) worthy of a bug
report?
Thanks.
-r

On Mon, Feb 22, 2010 at 9:04 PM, Roger P. [email protected]
wrote:

Looks like with jruby HEAD --server, it now takes 2.4s in jruby, still
0.64 in 1.8.7

Just a side note:
–server is known to be slower at things like that, so for the faster
startup --client option is much more preferrable.

–Vladimir


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Vladimir S. wrote:

On Mon, Feb 22, 2010 at 9:04 PM, Roger P. [email protected]
wrote:

Looks like with jruby HEAD --server, it now takes 2.4s in jruby, still
0.64 in 1.8.7

Just a side note:
–server is known to be slower at things like that, so for the faster
startup --client option is much more preferrable.

Interesting.
Looks like with --server it takes 2.4s (warm), without it, 2.15s
So a tidge faster :slight_smile:

-r

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