-
-
Save kuntoaji/aeb00036974ba444bdf6 to your computer and use it in GitHub Desktop.
Revisions
-
jjb revised this gist
Nov 9, 2013 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,7 +23,8 @@ default: 1.8 not available in ruby 2.0 Next time Ruby needs new heap slots it will this multiplier to determine how much memory to allocate. See RUBY_HEAP_SLOTS_INCREMENT for discussion of what this is multiplying. ### RUBY_HEAP_SLOTS_GROWTH_MAX default: 0 (disable) @@ -59,7 +60,7 @@ not available in ruby 2.0 ### RUBY_HEAP_SLOTS_INCREMENT **Not available in MRI. Instead of a definable slot size, MRI uses [the logic in this code](https://github.com/ruby/ruby/blob/9782d219f34aded1d0b80f7bdff809132550561e/gc.c#L1138-L1152), which I have so far not been able to grok, to determine the slot size.** The number of new slots to allocate when all initial slots are used -
jjb revised this gist
Nov 9, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ default: 10000 The number of heap slots to start out with. This should be set high enough so that your app has enough or almost enough memory after loading so that it doesn't have to allocate more memory on the first request (althogh this probably isn't such a big deal for most apps). (todo: figure out how big a slot is. i think the answer can be infered from [this code](https://github.com/ruby/ruby/blob/9782d219f34aded1d0b80f7bdff809132550561e/gc.c#L5240-L5248).) ### RUBY_FREE_MIN default: 4096 -
jjb revised this gist
Nov 9, 2013 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,6 @@ This all applies to Ruby 2.1. In some cases a setting is not available in 2.0, this is noted. There is also a different with 1.9, 1.8, and REE --- these are not noted. All the relevant code is in https://github.com/ruby/ruby/blob/trunk/gc.c ### RUBY_HEAP_MIN_SLOTS default: 10000 -
jjb revised this gist
Nov 9, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -78,7 +78,7 @@ listed [here](http://www.rubyenterpriseedition.com/documentation.html#_garbage_c ``` RUBY_HEAP_MIN_SLOTS=600000 RUBY_GC_MALLOC_LIMIT=59000000 RUBY_FREE_MIN=100000 ``` ### twitter -
jjb revised this gist
Nov 9, 2013 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,11 +19,15 @@ I don't really understand what this means. Since ruby never gives back memory th ### RUBY_HEAP_SLOTS_GROWTH_FACTOR default: 1.8 not available in ruby 2.0 ??? ### RUBY_HEAP_SLOTS_GROWTH_MAX default: 0 (disable) not available in ruby 2.0 ??? ### RUBY_GC_MALLOC_LIMIT @@ -40,11 +44,15 @@ The ideal scenario would be to do GC asynchronosly from requests. Phusion Passen ### RUBY_GC_MALLOC_LIMIT_MAX default: 32 * 1024 * 1024 (32MB) not available in ruby 2.0 ??? ### RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR default: 1.4 not available in ruby 2.0 ??? ### RUBY_HEAP_SLOTS_INCREMENT -
jjb revised this gist
Nov 9, 2013 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -60,6 +60,10 @@ The number of new slots to allocate when all initial slots are used [source](http://meta.discourse.org/t/tuning-ruby-and-rails-for-discourse/4126) ``` RUBY_GC_MALLOC_LIMIT=90000000 ``` ### 37 singnals listed [here](http://www.rubyenterpriseedition.com/documentation.html#_garbage_collector_performance_tuning), source unknown -
jjb revised this gist
Nov 9, 2013 . 1 changed file with 9 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -31,7 +31,10 @@ default: 16 * 1024 * 1024 (16MB) The number of C data structures that can be allocated before triggering the garbage collector. In the context of a web application, if this is set lower than the objects that are generated in a single request, then ruby will have to pause to do GC once or more than once for every request. (Here is a discussion of this setting and how to profile it)[http://meta.discourse.org/t/tuning-ruby-and-rails-for-discourse/4126]. The ideal scenario would be to do GC asynchronosly from requests. Phusion Passenger [has this feature](http://blog.phusion.nl/2013/01/22/phusion-passenger-4-technology-preview-out-of-band-work/). [So does unicorn](http://unicorn.bogomips.org/Unicorn/OobGC.html). Seems like it it could be achieved with middleware but I'm surprised there isn't a solution out there. ### RUBY_GC_MALLOC_LIMIT_MAX @@ -53,6 +56,10 @@ The number of new slots to allocate when all initial slots are used ## config used by famous people ### Discourse [source](http://meta.discourse.org/t/tuning-ruby-and-rails-for-discourse/4126) ### 37 singnals listed [here](http://www.rubyenterpriseedition.com/documentation.html#_garbage_collector_performance_tuning), source unknown @@ -74,7 +81,7 @@ RUBY_GC_MALLOC_LIMIT=50000000 ## references / further reading * http://snaprails.tumblr.com/post/241746095/rubys-gc-configuration (includes old/incorrect references to RUBY_HEAP_FREE_MIN) * http://meta.discourse.org/t/tuning-ruby-and-rails-for-discourse/4126 ## appendix: memory config in ruby source reference -
jjb revised this gist
Nov 9, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -31,7 +31,7 @@ default: 16 * 1024 * 1024 (16MB) The number of C data structures that can be allocated before triggering the garbage collector. In the context of a web application, if this is set lower than the objects that are generated in a single request, then ruby will have to pause to do GC once or more than once for every request. The ideal scenario would be to do GC asynchronosly from requests. Phusion Passenger [has this feature](http://blog.phusion.nl/2013/01/22/phusion-passenger-4-technology-preview-out-of-band-work/). [So does unicorn](http://unicorn.bogomips.org/Unicorn/OobGC.html). Seems like it it could be achieved with middleware but I'm surprised there isn't a solution out there. ### RUBY_GC_MALLOC_LIMIT_MAX -
jjb revised this gist
Nov 9, 2013 . 1 changed file with 55 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,26 +3,81 @@ This all applies to Ruby 2.1, I haven't checked if/how it differs from 2.0 ### RUBY_HEAP_MIN_SLOTS default: 10000 The number of heap slots to start out with. This should be set high enough so that your app has enough or almost enough memory after loading so that it doesn't have to allocate more memory on the first request (althogh this probably isn't such a big deal for most apps). (todo: figure out how big a slot is) ### RUBY_FREE_MIN default: 4096 The number of free slots that should be present after GC finishes running. I don't really understand what this means. Since ruby never gives back memory that it took, and GC is done independent of allocation, why would the post-GC count of free slots have any meaning? *note: this was formerly known in REE as RUBY_HEAP_FREE_MIN, and some guides I've seen erroneously use it for MRI as well* ### RUBY_HEAP_SLOTS_GROWTH_FACTOR default: 1.8 ??? ### RUBY_HEAP_SLOTS_GROWTH_MAX default: 0 (disable) ??? ### RUBY_GC_MALLOC_LIMIT default: 16 * 1024 * 1024 (16MB) The number of C data structures that can be allocated before triggering the garbage collector. In the context of a web application, if this is set lower than the objects that are generated in a single request, then ruby will have to pause to do GC once or more than once for every request. The ideal scenario would be to do GC asynchronosly from requests. Phusion Passenger has this feature. AFAIK there is no way to do this otherwise. ### RUBY_GC_MALLOC_LIMIT_MAX default: 32 * 1024 * 1024 (32MB) ??? ### RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR default: 1.4 ??? ### RUBY_HEAP_SLOTS_INCREMENT **Not available in MRI. However I think I read that this is the same as RUBY_HEAP_MIN_SLOTS, I'll try to figure this out.** The number of new slots to allocate when all initial slots are used ## config used by famous people ### 37 singnals listed [here](http://www.rubyenterpriseedition.com/documentation.html#_garbage_collector_performance_tuning), source unknown ``` RUBY_HEAP_MIN_SLOTS=600000 RUBY_GC_MALLOC_LIMIT=59000000 RUBY_HEAP_FREE_MIN=100000 ``` ### twitter listed [here](http://www.rubyenterpriseedition.com/documentation.html#_garbage_collector_performance_tuning), source unknown ``` RUBY_HEAP_MIN_SLOTS=500000 RUBY_HEAP_SLOTS_INCREMENT=250000 # not available in MRI RUBY_HEAP_SLOTS_GROWTH_FACTOR=1 RUBY_GC_MALLOC_LIMIT=50000000 ``` ## references / further reading * http://snaprails.tumblr.com/post/241746095/rubys-gc-configuration (includes old/incorrect references to RUBY_HEAP_FREE_MIN) * ## appendix: memory config in ruby source reference ``` ENV config MRI constant MRI variable -
jjb revised this gist
Nov 9, 2013 . 1 changed file with 13 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,25 @@ This all applies to Ruby 2.1, I haven't checked if/how it differs from 2.0 ### RUBY_HEAP_MIN_SLOTS default: 10000 ### RUBY_FREE_MIN default: 4096 ### RUBY_HEAP_SLOTS_GROWTH_FACTOR default: 1.8 ### RUBY_HEAP_SLOTS_GROWTH_MAX default: 0 (disable) ### RUBY_GC_MALLOC_LIMIT default: 16 * 1024 * 1024 (16MB) ### RUBY_GC_MALLOC_LIMIT_MAX default: 32 * 1024 * 1024 (32MB) ### RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR default: 1.4 ## appendix: memory config in ruby source reference -
jjb revised this gist
Nov 9, 2013 . 1 changed file with 9 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,16 +11,15 @@ default: 10000 ### RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR ## appendix: memory config in ruby source reference ``` ENV config MRI constant MRI variable RUBY_HEAP_MIN_SLOTS GC_HEAP_MIN_SLOTS initial_heap_min_slots RUBY_FREE_MIN GC_HEAP_MIN_FREE_SLOTS initial_heap_min_free_slots RUBY_HEAP_SLOTS_GROWTH_FACTOR GC_HEAP_GROWTH_FACTOR initial_growth_factor RUBY_HEAP_SLOTS_GROWTH_MAX GC_HEAP_GROWTH_MAX initial_growth_max RUBY_GC_MALLOC_LIMIT GC_MALLOC_LIMIT initial_malloc_limit RUBY_GC_MALLOC_LIMIT_MAX GC_MALLOC_LIMIT_MAX initial_malloc_limit_max RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR GC_MALLOC_LIMIT_GROWTH_FACTOR initial_malloc_limit_growth_factor ``` -
jjb revised this gist
Nov 9, 2013 . 1 changed file with 9 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,6 +13,14 @@ default: 10000 ## appendix: memory config in ruby source refernece ``` ENV config MRI constant MRI variable RUBY_FREE_MIN RUBY_HEAP_MIN_SLOTS RUBY_HEAP_SLOTS_GROWTH_FACTOR RUBY_HEAP_SLOTS_GROWTH_MAX RUBY_GC_MALLOC_LIMIT RUBY_GC_MALLOC_LIMIT_MAX RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR ``` -
jjb revised this gist
Nov 9, 2013 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,8 @@ default: 10000 ### RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR ## appendix: memory config in ruby source refernece ``` ENV config MRI constant MRI variable ``` -
jjb revised this gist
Nov 9, 2013 . 1 changed file with 13 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,17 @@ This all applies to Ruby 2.1, I haven't checked if/how it differs from 2.0 ### RUBY_FREE_MIN default: 10000 ### RUBY_HEAP_MIN_SLOTS ### RUBY_HEAP_SLOTS_GROWTH_FACTOR ### RUBY_HEAP_SLOTS_GROWTH_MAX ### RUBY_GC_MALLOC_LIMIT ### RUBY_GC_MALLOC_LIMIT_MAX ### RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR appendix |one|two|three| |four|five|six| -
jjb created this gist
Nov 9, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ This all applies to Ruby 2.1, I haven't checked if/how it differs from 2.0 Available memory config: ## RUBY_FREE_MIN ## RUBY_HEAP_MIN_SLOTS ## RUBY_HEAP_SLOTS_GROWTH_FACTOR ## RUBY_HEAP_SLOTS_GROWTH_MAX ## RUBY_GC_MALLOC_LIMIT ## RUBY_GC_MALLOC_LIMIT_MAX ## RUBY_GC_MALLOC_LIMIT_GROWTH_FACTOR