Skip to content

Commit 5133050

Browse files
committed
Fix bug with heap->skip_sweep_continue that affects performance
1 parent 7792190 commit 5133050

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

gc/default/default.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4685,9 +4685,13 @@ gc_sweep_step_worker(rb_objspace_t *objspace, rb_heap_t *heap)
46854685
return;
46864686
}
46874687
else if (heap->skip_sweep_continue) {
4688-
psweep_debug(-2, "[sweep] gc_sweep_step_worker: heap:%p (%ld) - skip_continue (early return)\n", heap, heap - heaps);
4689-
heap->skip_sweep_continue = false;
4690-
return;
4688+
if (objspace->background_sweep_mode) {
4689+
heap->skip_sweep_continue = false;
4690+
} else {
4691+
psweep_debug(-2, "[sweep] gc_sweep_step_worker: heap:%p (%ld) - skip_continue (early return)\n", heap, heap - heaps);
4692+
heap->skip_sweep_continue = false;
4693+
return;
4694+
}
46914695
}
46924696
while (1) {
46934697
struct heap_page *sweep_page = heap->sweeping_page;
@@ -5547,8 +5551,8 @@ gc_sweep_continue(rb_objspace_t *objspace, rb_heap_t *sweep_heap)
55475551
heap->pre_swept_slots_deferred = 0;
55485552
}
55495553
if (num_heaps_need_continue > 0) {
5550-
objspace->sweep_thread_sweep_requested = true;
55515554
if (!objspace->sweep_thread_sweeping && !objspace->sweep_thread_sweep_requested) {
5555+
objspace->sweep_thread_sweep_requested = true;
55525556
psweep_debug(-2, "[gc] gc_sweep_continue: requesting sweep thread\n");
55535557
}
55545558
else {

0 commit comments

Comments
 (0)