[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

OSX: require seems very slow

Matt Wynne

10/29/2008 12:51:00 PM

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-rai...
--
Posted via http://www.ruby-....

3 Answers

Trans

10/29/2008 4:19:00 PM

0



On Oct 29, 8:51=A0am, Matt Wynne <m...@mattwynne.net> wrote:
> 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.

Matt Wynne

10/29/2008 5:03:00 PM

0

Thomas Sawyer wrote:
> 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-...to...
[2]http://www.ruby-...to...
--
Posted via http://www.ruby-....

Robert Klemme

10/30/2008 10:07:00 AM

0

2008/10/29 Matt Wynne <matt@mattwynne.net>:

> 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

--
remember.guy do |as, often| as.you_can - without end