How to install tcmalloc and speed up ruby

Use:

sudo apt-get install libgoogle-perftools-dev

then you can speed up your ruby by doing the following:

 export RUBY_GC_MALLOC_LIMIT=1000000000
 export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1.25
 export RUBY_HEAP_MIN_SLOTS=800000
 export RUBY_FREE_MIN=600000
 export LD_PRELOAD=/usr/lib/libtcmalloc_minimal.so.4
Advertisements