OSX: require seems very slow

M

Matt Wynne

Hi,

I'm working on a large rails app on my MacBook Pro (2.16 GHz Intel Core
Duo / 2GB RAM). OS X is 10.5.5.

On my machine, it takes about 30 seconds to load the rails environment
for our project. For my colleagues, who are mostly using Ubuntu, it's
much faster.

I've done some basic profiling and it looks as though the time is being
spent simply requiring files.

I made a very simple script and got my colleagues to run it:

t = Time.now]
require 'rubygems'
require 'activesupport'
puts Time.now - s

They're mostly getting sub-second performance, while on my machine it
takes over 3 seconds, just to load ActiveSupport.

Can anyone explain what is going on, and better, how to speed this up
for me? Or should I just live with this? Is this comparable to other
people's experience on a Mac?

FYI, ruby -v says
ruby 1.8.6 (2007-09-24 patchlevel 111) [i686-darwin9.5.0]

This is after I built ruby from source to try and resolve this,
following[1]. It has made little difference, in fact if anything things
seem to be even slower since I switched my path to use /usr/local/bin
rather than the one installed with Leopard.

Thanks in advance,
Matt

[1]http://hivelogic.com/articles/2008/02/ruby-rails-leopard
 
T

Trans

Hi,

I'm working on a large rails app on my MacBook Pro (2.16 GHz Intel Core
Duo / 2GB RAM). OS X is 10.5.5.

On my machine, it takes about 30 seconds to load the rails environment
for our project. For my colleagues, who are mostly using Ubuntu, it's
much faster.

I've done some basic profiling and it looks as though the time is being
spent simply requiring files.

I made a very simple script and got my colleagues to run it:

=A0 =A0 t =3D Time.now]
=A0 =A0 require 'rubygems'
=A0 =A0 require 'activesupport'
=A0 =A0 puts Time.now - s

They're mostly getting sub-second performance, while on my machine it
takes over 3 seconds, just to load ActiveSupport.

ActiveSupport is pretty big and goes about things in a very round
about way. So it is a slow to load regardless. However, 3 seconds does
seem overly slow.

Some comparison could help evaluate the problem. Try installing facets
(gem install facets) and time how long it take to require 'facets'.
That's another big library, but simpler in design. If that take more
than a second than something is seriously wrong.

T.
 
M

Matt Wynne

Thomas said:
ActiveSupport is pretty big and goes about things in a very round
about way. So it is a slow to load regardless. However, 3 seconds does
seem overly slow.

So, an update: I discovered this thread[1] and this one[2] and tried
rebuilding ruby with -O3 and --disable-pthreads, and things have got a
bit better.

My benchmark test now takes about 1.2 seconds.

However the benchmark from [2] takes about 44 seconds, which is
appalling in comparison to the scores from similar machines on that
thread.

I have very little idea what I'm going when building things from source,
but I feel as if I'm on to something here. Any pointers appreciated very
much.
Some comparison could help evaluate the problem. Try installing facets
(gem install facets) and time how long it take to require 'facets'.
That's another big library, but simpler in design. If that take more
than a second than something is seriously wrong.

Nope, that's comparatively really quick, like 0.3 secs max.

[1]http://www.ruby-forum.com/topic/162774
[2]http://www.ruby-forum.com/topic/125344
 
R

Robert Klemme

2008/10/29 Matt Wynne said:
I have very little idea what I'm going when building things from source,
but I feel as if I'm on to something here. Any pointers appreciated very
much.

Maybe you have an extremely lenghty library path or directories reside
on slow disks (e.g. NFS on a different machine, potentially with
network trouble). You can check the path with

ruby -e 'puts $:'

Kind regards

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top