# OSX: require seems very slow

**URL:** <https://www.ruby-forum.com/t/osx-require-seems-very-slow/152049>\
**Category:** Ruby\
**Created:** [October 29, 2008, 1:51pm UTC](https://www.ruby-forum.com/t/osx-require-seems-very-slow/152049 "2008-10-29T13:51:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwalsh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/91b2a8/32.png) [@mwalsh](https://www.ruby-forum.com/u/mwalsh)\
**Post date:** [October 29, 2008, 1:51pm UTC](https://www.ruby-forum.com/t/osx-require-seems-very-slow/152049/1 "2008-10-29T13:51:50Z")

</div>

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][Dan Benjamin](http://hivelogic.com/articles/2008/02/ruby-rails-leopard)

---

<div class="post-metadata">

**Author:** ![mwalsh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/91b2a8/32.png) [@mwalsh](https://www.ruby-forum.com/u/mwalsh)\
**Post date:** [October 29, 2008, 5:20pm UTC](https://www.ruby-forum.com/t/osx-require-seems-very-slow/152049/2 "2008-10-29T17:20:20Z")

</div>

On Oct 29, 8:51 am, Matt W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 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.

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.

---

<div class="post-metadata">

**Author:** ![mwalsh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/91b2a8/32.png) [@mwalsh](https://www.ruby-forum.com/u/mwalsh)\
**Post date:** [October 30, 2008, 11:08am UTC](https://www.ruby-forum.com/t/osx-require-seems-very-slow/152049/3 "2008-10-30T11:08:30Z")

</div>

2008/10/29 Matt W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> 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

---

<div class="post-metadata">

**Author:** ![mwalsh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/91b2a8/32.png) [@mwalsh](https://www.ruby-forum.com/u/mwalsh)\
**Post date:** [October 29, 2008, 6:03pm UTC](https://www.ruby-forum.com/t/osx-require-seems-very-slow/152049/4 "2008-10-29T18:03:54Z")

</div>

Thomas S. 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-forum.com/topic/162774](http://www.ruby-forum.com/topic/162774)  
[2][How fast does your Ruby run? - Ruby - Ruby-Forum](http://www.ruby-forum.com/topic/125344)
