[前][次][番号順一覧][スレッド一覧]

ruby-changes:71082

From: Peter <ko1@a...>
Date: Thu, 3 Feb 2022 23:22:49 +0900 (JST)
Subject: [ruby-changes:71082] 424374d330 (master): Fix case when gc_marks_continue does not yield slots

https://git.ruby-lang.org/ruby.git/commit/?id=424374d330

From 424374d3302d8d25165007e7afedf14b1a76d23e Mon Sep 17 00:00:00 2001
From: Peter Zhu <peter@p...>
Date: Wed, 2 Feb 2022 15:32:38 -0500
Subject: Fix case when gc_marks_continue does not yield slots

gc_marks_continue will start sweeping when it finishes marking. However,
if the heap we are trying to allocate into is full, then the sweeping
may not yield any free slots. If we don't call gc_sweep_continue
immediate after this, then another GC will be started halfway during
lazy sweeping. gc_sweep_continue will either grow the heap or finish
sweeping.
---
 gc.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/gc.c b/gc.c
index 4eaceef807..0309559481 100644
--- a/gc.c
+++ b/gc.c
@@ -2204,13 +2204,14 @@ heap_prepare(rb_objspace_t *objspace, rb_size_pool_t *size_pool, rb_heap_t *heap https://github.com/ruby/ruby/blob/trunk/gc.c#L2204
 {
     GC_ASSERT(heap->free_pages == NULL);
 
-    if (is_lazy_sweeping(objspace)) {
-	gc_sweep_continue(objspace, size_pool, heap);
-    }
-    else if (is_incremental_marking(objspace)) {
+    if (is_incremental_marking(objspace)) {
 	gc_marks_continue(objspace, size_pool, heap);
     }
 
+    if (heap->free_pages == NULL && is_lazy_sweeping(objspace)) {
+        gc_sweep_continue(objspace, size_pool, heap);
+    }
+
     if (heap->free_pages == NULL &&
         (will_be_incremental_marking(objspace) || heap_increment(objspace, size_pool, heap) == FALSE) &&
 	gc_start(objspace, GPR_FLAG_NEWOBJ) == FALSE) {
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]