5

In REE, and MRI 1.9+, ruby's garbage collector can be tuned:

But none of these articles say where to put this configuration. I imagine that if it's in the environment, ruby will pick it up when it starts -- however, there's no way to check this as far as I can tell. The settings don't show up in any runtime constants that I can find.

So, where do I put this configuration, and how can I double-check that it's being used?

John Bachir
  • 22,495
  • 29
  • 154
  • 227

1 Answers1

1

These settings are environment variables, so you would just need to set them in the parent process of the ruby process itself. Many people recommend creating a simple shell script for this purpose, perhaps calling it /usr/local/bin/ruby-custom:

#!/bin/bash
export RUBY_HEAP_MIN_SLOTS=20000
export RUBY_HEAP_SLOTS_INCREMENT=20000
...etc...
exec "/path/to/ruby" "$@"

The first few lines set whichever custom variables you want, and the last line invokes ruby itself, passing it whatever arguments this script was initially given.

You will next need to mark this script as executable (chmod a+x /usr/local/bin/ruby-custom) and then configure Passenger to use it as the ruby executable, by adding this to your Apache .conf file:

PassengerRuby /usr/local/bin/ruby-custom
Stuart M
  • 11,458
  • 6
  • 45
  • 59
  • thanks -- but what about the second question -- how can I double-check at runtime that the config has worked? (which is really my main question) – John Bachir Mar 26 '13 at 17:06
  • In Ruby 1.9+, you may be able to use [`GC.stat`](http://ruby-doc.org/core-1.9.3/GC.html#method-c-stat) to inspect some of these settings. Also note that REE is [end-of-life](http://blog.phusion.nl/2012/02/21/ruby-enterprise-edition-1-8-7-2012-02-released-end-of-life-imminent/) – Stuart M Mar 26 '13 at 17:11