Skip to content

Instantly share code, notes, and snippets.

@phoet
Created February 26, 2015 14:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save phoet/5da3d19aa72a6cdf798a to your computer and use it in GitHub Desktop.
Save phoet/5da3d19aa72a6cdf798a to your computer and use it in GitHub Desktop.
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