Skip to content

Instantly share code, notes, and snippets.

Last active May 23, 2018 09:01
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Tune Ruby garbage collector to improve test speed. This is also lead to enormous memory usage. More information about GC parameters tuning could be found in follow articles: [Chapter 4.2: "Garbage collector performance tuning" in Ruby Enterprise Edition (1.8.7)]( ["Ruby’s GC Configuration" …
# Allows to run GC less frequently which is significantly speed up specs running.
# Look for more detailed description in follow articles:
# - (Chapter 4.2: "Garbage collector performance tuning")
# -
# Initial number of heap slots. It also represents the minimum number of slots, at all times (default: 10000)
#export RUBY_HEAP_MIN_SLOTS=1000000 # for Rubies < 2.1
export RUBY_GC_HEAP_INIT_SLOTS=1000000 # for Rubies >= 2.1.0
# The number of new slots to allocate when all initial slots are used (default: 10000)
# Next time Ruby needs new heap slots it will use a multiplicator, defined by this environment variable’s value
# (default: 1.8, meaning it will allocate 18000 new slots if default settings are in use)
# The number of C data structures that can be allocated before triggering the garbage collector.
# This one is very important since the default value makes the GC run when there are still empty
# heap slots because Rails allocates and deallocates a lot of data (default: 8000000)
export RUBY_GC_MALLOC_LIMIT=100000000
# The number of free slots that should be present after GC finishes running.
# If there are fewer slots than those defined it will allocate new ones according
export RUBY_HEAP_FREE_MIN=500000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment