diff options
author | Peter Zhu <peter@peterzhu.ca> | 2023-08-28 16:34:27 -0400 |
---|---|---|
committer | Peter Zhu <peter@peterzhu.ca> | 2023-08-28 18:01:29 -0400 |
commit | fd0df1f8c6845671c86eddd85c9bcced30501690 (patch) | |
tree | 5e402dc35fdbfe5b089f1dd55eaf2db21ca4ea3c /gc.c | |
parent | 5485680244bc40a9dba52e468fc5705973f2f5bd (diff) |
Fix growth in minor GC when we have initial slots
If initial slots is set, then during a minor GC, if we have allocatable
pages but the heap is mostly full, then we will set `grow_heap` to true
since `total_slots` does not count allocatable pages so it will be less
than `init_slots`. This can cause `allocatable_pages` to grow to much
higher than desired since it will appear that the heap is mostly full.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/8310
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -5689,12 +5689,11 @@ gc_sweep_finish_size_pool(rb_objspace_t *objspace, rb_size_pool_t *size_pool) if (swept_slots < min_free_slots) { bool grow_heap = is_full_marking(objspace); - if (!is_full_marking(objspace)) { - /* The heap is a growth heap if it freed more slots than had empty - * slots and used up all of its allocatable pages. */ - bool is_growth_heap = (size_pool->empty_slots == 0 || - size_pool->freed_slots > size_pool->empty_slots) && - size_pool->allocatable_pages == 0; + /* Consider growing or starting a major GC if we are not currently in a + * major GC and we can't allocate any more pages. */ + if (!is_full_marking(objspace) && size_pool->allocatable_pages == 0) { + /* The heap is a growth heap if it freed more slots than had empty slots. */ + bool is_growth_heap = size_pool->empty_slots == 0 || size_pool->freed_slots > size_pool->empty_slots; /* Grow this heap if we haven't run at least RVALUE_OLD_AGE minor * GC since the last major GC or if this heap is smaller than the |