[ANN] frubygems -- quicker loading rubygems:"spooky" version

Please to announce release code-named “spooky” of fast rubygems.

Changelog:
added ‘frubygems’
as an additional require option

Synopsis:
require ‘frubygems’ # takes about 1/5th the time of doing a require
‘rubygems’

Essentially gem_prelude for 1.8

README:

A helper to dramatically speedup the time it takes to load rubygems

require ‘rubygems’ no longer has to sap valuable time from your life

inspired by a request from Yehuda K. [1] and 1.9’s fast gem_prelude.

Speed difference (windows box, lots of gem):

$ time ruby examples/require_rubygems_normal.rb

real 0m1.109s

$ time ruby examples/require_fast_start.rb

real 0m0.500s

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

It acts about the same as gem_prelude (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 ==

git clone git://github.com/rogerdpack/faster_rubygems.git
ruby faster_rubygems/install.rb # done!

== usage ==
instead of
require ‘rubygems’
it’s either
require ‘frubygems.rb’
or
require ‘rubygems_fast.rb’
(both do the same thing, first is to save key strokes)
in your scripts.

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

For those interested, speed difference example on linux (250 gems):
$ time ruby examples/require_rubygems_normal.rb
ruby examples/require_rubygems_normal.rb 0.57s user 0.05s system 85%
cpu 0.726 total

$ time ruby examples/require_fast_start.rb
ruby examples/require_fast_start.rb 0.04s user 0.02s system 46% cpu
0.121 total

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, and I’m not aware of any).

Note: you don’t need this for ruby 1.9, which already preloads via
gem_prelude, but it won’t hurt to use it in 1.9–it
defaults to a no-op, so doesn’t hurt.

On Oct 26, 6:44 pm, Roger P. [email protected] wrote:

Essentially gem_prelude for 1.8

git clone git://github.com/rogerdpack/faster_rubygems.git
ruby faster_rubygems/install.rb # done!

Roger: your username is no longer that, is rdp.

So the command ends being:

git clone git://github.com/rdp/faster_rubygems.git

so it ends up being git clone git://github.com/rdp/faster_rubygems.git

oops yep thanks for the correction.

This returns an Array

handle ENV[‘GEM_PATH’] if it exists

gem_paths << ENV[‘GEM_PATH’].split(’:’).select{|path| path + ‘/.gems’}
if ENV[‘GEM_PATH’] # TODO should this override or supplement?

so you end up with a gem_paths with Strings and an Array at the end.
Blows up at line 21.

gotcha so I misused << I believe.
Should be fixed now give it a shot.
git clone git://github.com/rdp/faster_rubygems.git
-=r

On Tue, 27 Oct 2009 06:44:50 +0900, Roger P. wrote:

Please to announce release code-named “spooky” of fast rubygems.

I think I found a bug in install.rb, line 12

This returns an Array

handle ENV[‘GEM_PATH’] if it exists

gem_paths << ENV[‘GEM_PATH’].split(’:’).select{|path| path + ‘/.gems’}
if ENV[‘GEM_PATH’] # TODO should this override or supplement?

so you end up with a gem_paths with Strings and an Array at the end.
Blows up at line 21.

Fix:
19 for gem_path in gem_paths.flatten do

:slight_smile:

This should afflict all RVM users that uses a non-standard location for
their gems/libs.