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!

I do both this patch and a patch that allows garbage collection to be tuned the same way as REE, so that it doesn’t start garbage collection while booting Rails. Works like a charm.
I don’t even give it a different name, made it my default 1.9.2 version.
Iain, can you point me to the right direction if I also want to apply that REE-like patch to Ruby? Thanks
Attila, I think this answers your question: http://metaskills.net/2011/03/09/gc-tune-ruby-1.9.2-with-rvm/
Got this error
[2011-11-07 13:53:27] make
gcc -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -fPIC -I. -I.ext/include/x86_64-linux -I./include -I. -DRUBY_EXPORT -o miniprelude.o -c miniprelude.c
In file included from miniprelude.c:7:0:
vm_core.h:321:22: error: duplicate member ‘loaded_features_hash’
vm_core.h:322:22: error: duplicate member ‘filename_expansion_hash’
vm_core.h:323:22: error: duplicate member ‘loaded_features_hash’
vm_core.h:324:22: error: duplicate member ‘filename_expansion_hash’
make: *** [miniprelude.o] Error 1