Tune Your 1.9.2 Garbage Collector on EY, Profit

For those of you who have NOT seen James Golick’s cloud performance talk: http://vimeo.com/12814529, time well spent.

Of course, I myself love the cloud for all the right reasons, such as API based deployments and all that jazz. You see, I cannot quite afford a sysadmin and I sure as hell cannot afford to be a sysadmin, but I digress

Yes, 1.9.2

This was news to me too, but if you read the press release carefully, you will notice it too:

We’re very excited about Ruby 1.9.2 as the future of the MRI series of Rubies. Our particular build of MRI Ruby 1.9.2 includes customizable GC extensions.

I found this very interesting, and some hours later came up with a simple working solution in the form of a ey-cloud-recipes branch+commit

The bit of interest is this:

if GC.respond_to?(:malloc_limit=)
  GC.malloc_limit = 79000000
end

if GC.respond_to?(:heap_min_slots=)
  GC.heap_min_slots = 800000
end

if GC.respond_to?(:free_min=)
  GC.free_min = 100000
end

For now, these are the only three that I found. As you may have guessed, I did it with:

GC.methods #=>
[:start, :enable, :disable, :stress, :stress=, :count,
:malloc_limit, :malloc_limit=, :heap_min_slots, :heap_min_slots=,
:free_min, :free_min=, ...]

So take a look what this did to a fairly large Rails project that seeks performance support from both Memcache as well as Solr:

No reason NOT to tune your 1.9.2