Garbage collector tuning in Ruby 1.9

后端 未结 2 571
说谎
说谎 2021-02-04 03:26

I know about GC.enable/disable, but is there any way of controlling the Ruby 1.9 garbage collector in more detail?

When profiling my code

相关标签:
2条回答
  • 2021-02-04 04:02

    No.

    There is no way to tune the 1.9.0–1.9.2 GC. However, you can compile a custom VM that exposes more or less the same tuning parameters as REE with this patch.

    0 讨论(0)
  • 2021-02-04 04:06

    Yep, for short.

    At first, basic constants, defining GC behavior (defaults value are shown) :

    • RUBY_GC_MALLOC_LIMIT = 8000000 # - Initial size of a new memory slab, which is allocated after consuming all available memory
    • RUBY_HEAP_MIN_SLOTS = 10000 #- Initial memory size, allocated at startup
    • RUBY_HEAP_SLOTS_GROWTH_FACTOR = 1,8 #- New slab of memory is X times bigger than previous after each allocation.
    • RUBY_HEAP_SLOTS_INCREMENT = 1 # Not sure, honestly :)

    More details about GC, may help

    A story from 37signals guys, which may definitively help you. They used manual GC calls (GC.start) on time, instead of memory size, and got huge boost.

    0 讨论(0)
提交回复
热议问题