Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to patch ruby for GC tuning and faster requiring
case "$rvm_ruby_string" in
*ruby-1.9.2*-patched)
export RUBY_HEAP_MIN_SLOTS=1000000
export RUBY_HEAP_SLOTS_INCREMENT=1000000
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
export RUBY_GC_MALLOC_LIMIT=1000000000
export RUBY_HEAP_FREE_MIN=500000
export RUBY_FREE_MIN=$RUBY_HEAP_FREE_MIN
;;
*)
unset RUBY_HEAP_MIN_SLOTS RUBY_HEAP_SLOTS_INCREMENT RUBY_HEAP_SLOTS_GROWTH_FACTOR RUBY_GC_MALLOC_LIMIT RUBY_HEAP_FREE_MIN RUBY_FREE_MIN
;;
esac
# To use this hook for REE, replace line 2 with the following:
# *ree*|*ruby-1.9.2*-patched)
curl https://raw.github.com/gist/856296/patch-1.9.2-gc.patch > ~/192-gc.patch
curl https://raw.github.com/gist/1008945/load.patch > ~/192-load.patch
rvm get head
rvm reload
# create ruby called: ruby-1.9.2-p180-patched
rvm install ruby-1.9.2-p180 --patch ~/192-gc.patch --patch ~/192-load.patch -n patched
# create after_use hook to set desired ENV variables
curl https://raw.github.com/gist/1120753/after_use_192-patched.sh > $rvm_path/hooks/after_use_192-patched
chmod u+x $rvm_path/hooks/after_use_192-patched
rm ~/192-gc.patch ~/192-load.patch
@jswanner

This comment has been minimized.

Copy link
Owner Author

commented Aug 2, 2011

@jswanner

This comment has been minimized.

Copy link
Owner Author

commented Aug 2, 2011

The way this is written you will have a ruby version ending with "-patched", so you'll have to modify your .rvmrc files to use it. If you want to just patch the "standard" ruby version and not have a version called "xxx-patched": leave the -n patched option off of the rvm install command, and modify the after_use hook appropriately

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.