[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

[ANN] faster_rubygems: speedup rubygems' load time

Roger Pack

5/9/2009 4:22:00 AM

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

2 Answers

Eric Hodel

5/9/2009 4:33:00 AM

0

On May 8, 2009, at 21:21, Roger Pack wrote:
> == 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...

Roger Pack

5/9/2009 6:52:00 AM

0


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