Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
heroku GC settings generator for rails
namespace :heroku do
desc "generate GC settings"
task gc: [:environment] do
# https://discussion.heroku.com/t/tuning-rgengc-2-1-on-heroku/359/6
# http://tmm1.net/ruby21-rgengc/
# http://thorstenball.com/blog/2014/03/12/watching-understanding-ruby-2.1-garbage-collector/
# http://collectiveidea.com/blog/archives/2015/02/19/optimizing-rails-for-memory-usage-part-1-before-you-optimize/
settings = {
RUBY_GC_HEAP_FREE_SLOTS: 600000, # default is 4096,
RUBY_GC_HEAP_GROWTH_FACTOR: 1.25, # default is 1.8,
RUBY_GC_HEAP_GROWTH_MAX_SLOTS: 300000, # default is 0,
RUBY_GC_HEAP_INIT_SLOTS: 600000, # default is 10000,
RUBY_GC_MALLOC_LIMIT: 16.megabyte, # default is 16.megabyte,
RUBY_GC_MALLOC_LIMIT_MAX: 32.megabyte, # default is 32.megabyte,
RUBY_GC_OLDMALLOC_LIMIT: 16.megabyte, # default is 16.megabyte,
RUBY_GC_OLDMALLOC_LIMIT_MAX: 32.megabyte, # default is 32.megabyte,
}
puts "heroku config:add #{settings.map { |key, value| "#{key}=#{value}"}.join(' ') }"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment