Extremely slow start up with ruby 1.9.1 vs 1.8.7

Count me in :confused:

On ubuntu 10.10 with ruby 1.9.2 and a fresh rails 3.0.3. I created a cucumber feature with one scenario.

Running cucumber takes about 18 seconds, with 17 seconds spent doing calls to kernel#require.

See: https://gist.github.com/780747

Now, I installed ruby from ubuntu repos/ppa, which I am not sure it provided the latest ruby. So I removed everything and installed rvm. Installed ruby 1.9.2-p136 and had same issue. Then installed ree 1.8.7, and did not have the issue. It's much faster. I will watch closely the -core mailing list for a possible resolution, but for now, I will use ree.

See: https://gist.github.com/781489

Hi, in order to put your numbers below into context, can you post the spec for your hardware?

Thanks,

-Conrad

This issue in 1.9.2 was affecting me enough that I switched back to 1.8.7, but not without doing a bit of research in to what the problem was.

We see a performance loss in 1.9.2 as it exhibits the correct behaviour when calling require, whereas 1.8.7 is reliant on incorrect semantics that are not acceptable for production use. I was never affected by these incorrect semantics, but I suppose ruby-core has to right these things or accept the long term technical debt.

Something called gem_prelude was added to ruby 1.9 as kludge to address some performance issues.

Ryan David explain (from the ruby-core list):

It (gem_prelude) was created to address a symptom, namely, that rubygems was slow on some systems (and proportional to the number of gems you have installed).

The good news is: a patch was committed (Jan 14) to ruby that should address some of the performance issues we're seeing. Namely, 1.9.2 users will be able to upgrade to rubygems 1.4 which offers some improved performance.

I don't know when we'll see the next ruby release, but I'm encouraged to see some progress. I'm also encouraged to see that there are members of the ruby-core team actively investigating and addressing these issues.

Luke

Conrad Taylor wrote in post #975240:

Hi, in order to put your numbers below into context, can you post the spec for your hardware?

Thanks,

-Conrad

I was running the test on my laptop (core 2 duo 1.86ghz + 2gb ram + 5400rpm hdd). I might run the same test on my desktop (quad core 3.2 ghz + 4gb + 10000 rpm drive).

Also, with rvm, I think I can install ruby from head, see if it improves the performance problem.

Jp Jphpsf wrote in post #975316:

Also, with rvm, I think I can install ruby from head, see if it improves the performance problem.

I've installed ruby-head via rvm, and updated my gist. It does seem to be an improvement! Still lagging behind ree, though.

Using ruby-prof I captured the CPU time of the startup of my 3.0.3 Rails app (Profile rails code with/without rails load time and support valgrind output ยท GitHub):

...

ruby-1.9.2-p136 (Total CPU 16.794391)

%self total self wait child calls name 39.93 16.47 6.71 0.00 16.46 1904 Kernel#require   3.85 2.51 0.65 0.00 2.23 14252 Array#map

If require is your bottleneck, you can use the faster_require gem:

-r