Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Garbage collector tuning in Ruby 2.0

I was wondering if the GC tuning used for ruby 1.9.x is still relevant in 2.0 with the new implementation of the GC. If so, are there any new things that we can configure on the new version?

I am talking about the following setups

RUBY_HEAP_MIN_SLOTS=600000  RUBY_GC_MALLOC_LIMIT=59000000 RUBY_HEAP_FREE_MIN=100000 
like image 405
Fernando Diaz Garrido Avatar asked Apr 30 '13 12:04

Fernando Diaz Garrido


People also ask

What is garbage collection tuning?

What Is Garbage Collection Tuning. Garbage Collection GC tuning is the process of adjusting the startup parameters of your JVM-based application to match the desired results. Nothing more and nothing less. It can be as simple as adjusting the heap size – the -Xmx and -Xms parameters.

Does Ruby do garbage collection?

The Ruby Garbage Collector module is an interface to Ruby's mark and sweep garbage collection mechanism. While it runs automatically in the background when needed, the GC module lets you call the GC manually whenever required and gain insights into how garbage collection cycles are running.


1 Answers

There's a fair bit of confusion about these GC tuning parameters. REE (which is a fork of Ruby 1.8.7) introduced its own parameters first, and later Ruby (starting in 1.9.2) introduced its own (similar) parameters. Ruby 1.9.3 made them customizable via environment variables, and Ruby 2.1.0 added a lot more.

This blog post goes into great detail about garbage collection in MRI and what all the tuning variables mean.

Here's a complete list of all the tuning variables for each Ruby version:

REE source

  • RUBY_HEAP_MIN_SLOTS
  • RUBY_HEAP_SLOTS_INCREMENT
  • RUBY_HEAP_SLOTS_GROWTH_FACTOR
  • RUBY_GC_MALLOC_LIMIT
  • RUBY_HEAP_FREE_MIN

Ruby 1.9.2 source source

(Hard-coded, but customizable via environment variables with this patch)

  • GC_MALLOC_LIMIT
  • HEAP_MIN_SLOTS
  • FREE_MIN

Ruby 1.9.3 source

  • RUBY_GC_MALLOC_LIMIT
  • RUBY_HEAP_MIN_SLOTS
  • RUBY_FREE_MIN

Ruby 2.0.0 source

Same as Ruby 1.9.3

Ruby 2.1.0 source

  • RUBY_GC_HEAP_INIT_SLOTS (obsoletes RUBY_HEAP_MIN_SLOTS)
  • RUBY_GC_HEAP_FREE_SLOTS (obsoletes RUBY_FREE_MIN)
  • RUBY_GC_HEAP_GROWTH_FACTOR (new)
  • RUBY_GC_HEAP_GROWTH_MAX_SLOTS (new)
  • RUBY_GC_MALLOC_LIMIT
  • RUBY_GC_MALLOC_LIMIT_MAX (new)
  • RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR (new)
  • RUBY_GC_OLDMALLOC_LIMIT (new)
  • RUBY_GC_OLDMALLOC_LIMIT_MAX (new)
  • RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR (new)

Ruby 2.1.1 source

  • RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR (new)
like image 90
davogones Avatar answered Oct 09 '22 11:10

davogones