Speeding up Ruby 1.9.2 startup time


How to apply the patch for speeding up the awfully slow startup time of Ruby 1.9.2 scripts. This guide is for Mac OS X Snow Leopard.

First, install RVM:

bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

then add RVM to the last line of your /etc/bashrc:

[[ -s "/Users/minarik/.rvm/scripts/rvm" ]] && source "/Users/minarik/.rvm/scripts/rvm"

restart the Terminal

and make sure that RVM works:

rvm list

if you have the RVM version that says “~/.rvm/scripts/base: line 42: ~/.rvm/scripts/functions/bundler: No such file or directory”, then make this change to ~/.rvm/scripts/base:

@@ -39,7 +39,7 @@
-logging utility init cleanup env rvmrc install environment gemset db bundler
+logging utility init cleanup env rvmrc install environment gemset db

download the speed patch for ruby 1.9.2 p180 stable:

curl https://raw.github.com/gist/1008945/7532898172cd9f03b4c0d0db145bc2440dcbb2f6 > /tmp/load180.patch

compile ruby with that patch:

rvm install ruby-1.9.2-p180 --patch /tmp/load180.patch

set just compiled ruby as a default:

rvm --default use 1.9.2

That’s it, enjoy :)

blog comments powered by Disqus