In my last post, I showed how to install Ruby 1.9.3-p194 on OS X without Xcode or [OSX GCC Installer][osc_gcc_installer]. But, I didn’t cover how to install funny-falcon’s performance patches. I have another post which can show the speed benefits of using these patches.
The following steps assume you’ve followed steps 1-6 of my last
post; and, can be applied in addition to, or in replacement
of, steps 7-8. In these steps, we will install a new version of Ruby
which will be named
1.9.3-p194-perf, which you can keep as a separate
installation of Ruby from
1.9.3-p194, or it can be the only
installation of Ruby on your development environment.
$ brew install autoconf
$ curl "https://raw.github.com/gist/3126141/rbenv.sh" | sh
Optionally, set Ruby 1.9.3-p194-perf as global version to use:
$ rbenv global 1.9.3-p194-perf
Adjust Ruby environment variables
With those patches in place, we can now improve Ruby’s performance a bit more. Whenever Ruby’s garbage collector (GC) is running, nothing else can run; and, by default, Ruby’s settings are a bit conservative, potentially causing Ruby’s GC to run multiple times within a single Rails request. So, if we can allow Ruby to use more memory, while having the GC run less frequently, allowing more time for our code to run and less GC time, we can improve our applications’ performance.
$ cd ~/.rbenv/plugins $ git clone https://github.com/sstephenson/rbenv-vars.git
Add the following to
.rbenv-varsin a project directory:
RUBY_GC_MALLOC_LIMIT=1000000000 RUBY_HEAP_FREE_MIN=500000 RUBY_HEAP_MIN_SLOTS=1000000 RUBY_HEAP_SLOTS_GROWTH_FACTOR=1 RUBY_HEAP_SLOTS_INCREMENT=1000000