Xavier Shay has an awesome patch for making Ruby 1.9.3 start up faster by optimizing “require”. Our rails app is still on 1.9.2, since we’re big on not using a new version of a programming language until it’s, how do I say… released?

One of the commenters, Adam Palmblad, adapted the patch for 1.9.2, and here at work we’re happily using and loving it. Here’s an example benchmark while running a unit test:

# pre-patch 1.9.2 running a unit test
> time (for i in `seq 1 5`; do ruby -Ilib:test test/unit/repeats_test.rb; done)
...
111.80s user 5.42s system 101% cpu 1:56.03 total
 
# post-patch
> time (for i in `seq 1 5`; do ruby -Ilib:test test/unit/repeats_test.rb; done)
...
55.22s user 6.70s system 100% cpu 1:01.73 total

Convinced? Here are some quick instructions for getting going with it (assuming you have rvm installed)

# prereqs on ubuntu (adapt to your own system)
sudo apt-get build-dep ruby1.9
 
# build patched version (takes a couple minutes)
curl https://raw.github.com/gist/999435/fc2718ac3f488ab2341b65dc2ae5c123f8859bff/fast-require-ruby-19.2-p180 > /tmp/require-performance-fix.patch
rvm install 1.9.2-p180 --patch /tmp/require-performance-fix.patch -n patched
 
# get set up
cd /your/rails/app
rvm use ruby-1.9.2-p180-patched
gem install bundler --no-rdoc --no-ri
bundle

Celebrate!