Forum: Ruby why a require 'activerecord' takes up to 1 second?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3cca2409a87d4791155e912058c3ec38?d=identicon&s=25 Jay Jruby (jruby)
on 2009-03-29 19:30
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
753dcb78b3a3651127665da4bed3c782?d=identicon&s=25 Brian Candler (candlerb)
on 2009-03-30 10:33
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 :-)

> 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.
This topic is locked and can not be replied to.