Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A helper to dramatically speedup the time it takes to run a 'require rubygems'. DEPRECATED shouldn't be necessary with newer versions of rubygems, at least I hope not. If it is message me so I can work on this again
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
ext
lib
spec
README
Rakefile
VERSION
benchmarks.txt
internalize.rb

README

= Faster Rubygems =



This gem makes loading rubygems *much* faster.

What it does is cache the location of files in your gem dirs, ex:

/lib/ruby/gems/1.8/jruby/{active_support, active_record}

it creates this file:

/lib/ruby/gems/1.8/jruby/.faster_rubygems_cache

Then it uses *that* instead of loading full blown rubygems.


Timing (on doze with ~ 50 gems installed):

no rubygems at all:

$ jruby -e 1
0.68s.

require 'rubygems' time:

$ jruby -rubygems -e 1

2.36s normal rubygems: -> 0.94s with faster_rubygems

time to do a rake -V (get rake version):

$ jruby -S rake -V

2.48s with normal rubygems: -> 1.50s with faster_rubygems

(rake installed into site_ruby and loaded without rubygems takes 1.41s).  

Thus we see that loading of rubygems has decreased from 1.4s to between 0.1s and 0.3s


with mingw (windows).


normal rubygems:

  $ timer ruby whichr
  0.83s

with faster_rubygems:

  $ timer ruby whichr
  0.19s


linux:

 $ time ruby -S whichr whichr
     ruby 1.9: 0.6s -> 0.13s
     ruby 1.8: 0.17s -> 0.09s

 Thus we see that it helps startup time for 1.9 on Linux, but not much for 1.8 on Linux.

== installation ==

$ gem install faster_rubygems # installs faster_rubygems into your site lib, overrides normal rubygems

now there is a manual step that must be followed:

1.9

  Set this environment variable:
  RUBYOPT=-rfaster_rubygems --disable-gems

1.8:
  Installs itself by default.
  
  
Note that full rubygems will still be loaded when necessary (for example when installing new gems).  This is automatic.

Also note that using this reduces the memory footprint of your application by not having to load full rubygems, with its files and accompanying gemspecs, which are traditionally all re-loaded every time, but not with faster_rubygems.

== Rails ==

Unfortunately this gem does not greatly speed up rails--it speeds up any script that 
doesn't require full rubygems (which is most, but not rails).

If you want to speed up rails, you'll want to use the faster_require gem 
(though they do work together splendidly). http://github.com/rdp/faster_require

See http://github.com/rdp/faster_rubygems/blob/master/benchmarks.txt for a full breakdown and more benchmarks.

== Trouble Shooting ==

# if you wish to revert back to normal rubygems, do the following:
$ faster_rubygems --unoverride

If all else fails in this process (it has typically worked fine), you can 
reinstall normal rubygems by downloading its package (.tgz) and running ruby setup.rb within it.

To regenerate cache files (should never really be necessary, but if you for some reason think yours are stale) do the following:

$ faster_rubygems # by default it recaches what it can

Most of the credit for this gem goes to gem prelude and some ideas by Charles Nutter.

== Related projects ==

rubygems (of course)
http://github.com/fabien/minigems/tree/master
1.9's gem_prelude
http://www.ruby-forum.com/topic/191673
the Builder gem
http://github.com/jeremyevans/zozo

Source/feedback:

http://www.github.com/rdp/faster_rubygems
Something went wrong with that request. Please try again.