bear-metal / tunemygc

TuneMyGC - optimal MRI Ruby 2.1+ Garbage Collection
https://www.tunemygc.com
346 stars 25 forks source link

Option to optimise for lower memory usage #48

Open maia opened 6 years ago

maia commented 6 years ago

Using the Heroku add-on, I'm missing the option to optimise for minimal memory usage (rather than optimising for speed). Is there any hidden way to enable such an option?

The UI has a dropdown with ActionController as only option, but it's still possible to profile worker dynos by changing RUBY_GC_SPY. As there's another dropdown with "speed" as the only option next to it, I wonder if it also has a way to alter it.

The reason for asking is that the suggested values don't seem to take into account that my worker dyno is limited with 512MB. I'd like to keep the app's 95th percentile memory usage at ~420MB, as it allows me to quickly identify periods that need my attention.

I assume that tunemygc should then suggest lower values of RUBY_GC_HEAP_FREE_SLOTS and RUBY_GC_HEAP_GROWTH_MAX_SLOTS, but due to my rather limited knowledge this might be incorrect or incomplete.

Edit: Here are suggested and current settings for the mentioned 512MB worker dyno:

Variable………………………………………………………………………………Suggested……………Existing RUBY_GC_HEAP_INIT_SLOTS……………………………………………459_667………………419_430 RUBY_GC_HEAP_FREE_SLOTS………………………………………5_511_572…………………52_429 RUBY_GC_HEAP_GROWTH_FACTOR……………………………………………1.03………………………1.03 RUBY_GC_HEAP_GROWTH_MAX_SLOTS……………………………589_972………………209_715 RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR………………………1.2…………………………1.2 RUBY_GC_MALLOC_LIMIT……………………………………………20_132_659…………4_194_304 RUBY_GC_MALLOC_LIMIT_MAX…………………………………36_238_786………16_777_216 RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR………………………1.32…………………………1.2 RUBY_GC_OLDMALLOC_LIMIT……………………………………12_430_400…………4_194_304 RUBY_GC_OLDMALLOC_LIMIT_MAX…………………………22_374_720………16_777_216 RUBY_GC_OLDMALLOC_LIMIT_GROWTH_FACTOR…………………1.2…………………………1.2

Thanks!