Why a require 'activerecord' takes up to 1 second?


#1

Hi rubyers, this is my first post here.

Ok, I might not have the best machine in the World (Intel 2.66Mhz 1 CPU)
but I am doing some
“profiling” and realized that a “require ‘activerecord’” is taking about
1 second to perform.

I’m using ERuby, I’ve tried FastEruby/Erubis but without any noticeable
gain.

Any idea why this particular class is so heavy to load?
Would mod_ruby help?

Thank you,
Jay


#2

Jay Jruby wrote:

Hi rubyers, this is my first post here.

Ok, I might not have the best machine in the World (Intel 2.66Mhz 1 CPU)

It’s a long time since I used a machine as slow as 2.66MHz. Even the
original IBM PC-XT was 4.77MHz :slight_smile:

but I am doing some
“profiling” and realized that a “require ‘activerecord’” is taking about
1 second to perform.

I’m using ERuby, I’ve tried FastEruby/Erubis but without any noticeable
gain.

Any idea why this particular class is so heavy to load?

Look at its dependencies. e.g. try “require ‘activesupport’” before
“require ‘activerecord’” and time those two separately.

You could also try it without rubygems, e.g. instead of require
“rubygems” do
$:.unshift “/usr/lib/ruby/1.8/gems/1.8/activesupport-2.3.2/lib”
$:.unshift “/usr/lib/ruby/1.8/gems/1.8/activerecord-2.3.2/lib”
… etc

This is also a good way to find out what gem dependencies you have.

Regards,

Brian.