[ANN] faster_rubygems: speedup rubygems' load time

R

Roger Pack

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 Katz [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
 
E

Eric Hodel

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

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

Roger Pack

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
 

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

Forum statistics

Threads
473,981
Messages
2,570,187
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top