# \[ANN\] faster\_rubygems: speedup rubygems' load time

**URL:** <https://www.ruby-forum.com/t/ann-faster-rubygems-speedup-rubygems-load-time/167546>\
**Category:** Ruby\
**Created:** [May 9, 2009, 6:21am UTC](https://www.ruby-forum.com/t/ann-faster-rubygems-speedup-rubygems-load-time/167546 "2009-05-09T06:21:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [May 9, 2009, 6:21am UTC](https://www.ruby-forum.com/t/ann-faster-rubygems-speedup-rubygems-load-time/167546/1 "2009-05-09T06:21:46Z")

</div>

pleased to announce release of faster\_rubygems 0.0.1

description:  
A helper to dramatically speedup the time it takes to run  
require ‘rubygems’  
inspired by a request from Yehuda K. [1] and gem\_prelude (and not  
knowing if such a utility already existed or not…)

Example speed difference:

bash-3.1$ time ruby examples/require\_fast\_start.rb

real 0m0.500s  
bash-3.1$ time ruby examples/require\_rubygems.rb

real 0m1.109s

Yea! Finally ruby script startup times that don’t spend forever just  
reloading gem paths.

It acts about the same as gem\_prelude does (prelude is 1.9 only  
currently) – adds the paths of the highest version of each gem into  
your load path so they’re ready to be required.

== installation ==

How to install (manual for now–with any interest I could make it  
automatic):  
find your rubygems.rb file:  
ex from ubuntu:  
/usr/local/lib/ruby/site\_ruby/1.8/rubygems.rb  
from doze:  
c:\ruby18\lib\ruby\site\_ruby\1.8\rubygems.rb

# copy some files into that same directory:

git clone git://github.com/rogerdpack/faster\_rubygems.git  
cp faster\_rubygems/rubygems\_\*.rb /usr/local/lib/ruby/site\_ruby/1.8

== usage ==  
instead of  
require ‘rubygems’  
it’s  
require ‘rubygems\_fast.rb’  
or  
require ‘rubygems\_f.rb’ # shortcut to the first method.

Though if you were really clever I suppose you could figure out how to  
override the default rubygem behavior to do this, always:)

Speed difference example on linux:  
$ time ruby examples/require\_rubygems.rb

real 0m0.086s  
user 0m0.077s  
sys 0m0.008s  
$ time ruby examples/require\_fast\_start.rb

real 0m0.026s  
user 0m0.016s  
sys 0m0.008s

So better but not “such a big deal” as it is on windows boxes (where it  
can use up to 50% of script time). Also note that that’s on warm  
start–cold start might show higher differences. And it’s still a 4x  
speedup 🙂  
Note also that a few non conforming gems require the use of require  
‘rubygems’ no matter what (they’re pretty rare, though–you probably  
won’t run into them).

Thanks!  
-=r

[1]  
[http://rubyforge.org/tracker/index.php?func=detail&aid=21288&group\_id=126&atid=578](http://rubyforge.org/tracker/index.php?func=detail&aid=21288&group_id=126&atid=578)

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [May 9, 2009, 6:33am UTC](https://www.ruby-forum.com/t/ann-faster-rubygems-speedup-rubygems-load-time/167546/2 "2009-05-09T06:33:37Z")

</div>

On May 8, 2009, at 21:21, Roger P. wrote:

> # copy some files into that same directory:
> 
> git clone git://github.com/rogerdpack/faster\_rubygems.git  
> cp faster\_rubygems/rubygems\_\*.rb /usr/local/lib/ruby/site\_ruby/1.8

Why didn’t you make a gem that does this automatically via a command  
line tool or gem plugin? Not everybody has rubygems.rb installed in  
the same place…

---

<div class="post-metadata">

**Author:** ![rogerdpack](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/45deac/32.png) [@rogerdpack](https://www.ruby-forum.com/u/rogerdpack)\
**Post date:** [May 9, 2009, 8:51am UTC](https://www.ruby-forum.com/t/ann-faster-rubygems-speedup-rubygems-load-time/167546/3 "2009-05-09T08:51:30Z")

</div>

> Why didn’t you make a gem that does this automatically via a command  
> line tool or gem plugin? Not everybody has rubygems.rb installed in  
> the same place…

great idea.  
Now you can just run install.rb within the repo and it will install the  
necessary files where they need to go.

I also notice a slight difference in RAM usage–6MB goes to 3MB (that’s  
on a windows box with maybe 40 total gems).

Thanks.  
-=r
