Skip to content

Commit 57dc2fa

Browse files
committed
Turn back on sweep thread during GC.start
1 parent 5c82e2e commit 57dc2fa

1 file changed

Lines changed: 17 additions & 21 deletions

File tree

gc/default/default.c

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5431,10 +5431,6 @@ gc_sweep_start(rb_objspace_t *objspace)
54315431
bool do_signal = false;
54325432
if (objspace->sweep_thread &&
54335433
!objspace->flags.during_compacting &&
5434-
/* A major immediate GC sweeps the rest synchronously (gc_sweep_rest)
5435-
* right after this, so handing work to the background thread only adds
5436-
* lock contention with no chance to overlap. Keep it on the FG. */
5437-
!(is_full_marking(objspace) && objspace->flags.immediate_sweep) &&
54385434
!(objspace->hook_events & RUBY_INTERNAL_EVENT_FREEOBJ)) {
54395435
psweep_debug(-1, "[gc] gc_sweep_start: requesting sweep thread\n");
54405436
objspace->use_background_sweep_thread = true;
@@ -5960,23 +5956,23 @@ background_sweep_done_p(rb_objspace_t *objspace)
59605956
static void
59615957
gc_sweep_rest(rb_objspace_t *objspace)
59625958
{
5963-
/*#if USE_PARALLEL_SWEEP*/
5964-
/*bool do_signal = false;*/
5965-
/*sweep_lock_lock(objspace);*/
5966-
/*{*/
5967-
/*objspace->sweep_rest = true; // reset to false in `gc_sweeping_exit`*/
5968-
/*if (!background_sweep_done_p(objspace)) {*/
5969-
/*if (objspace->use_background_sweep_thread && !objspace->sweep_thread_sweeping && !objspace->sweep_thread_sweep_requested) {*/
5970-
/*do_signal = true;*/
5971-
/*objspace->sweep_thread_sweep_requested = true;*/
5972-
/*}*/
5973-
/*}*/
5974-
/*}*/
5975-
/*sweep_lock_unlock(objspace);*/
5976-
/*if (do_signal) {*/
5977-
/*rb_native_cond_signal(&objspace->sweep_cond);*/
5978-
/*}*/
5979-
/*#endif*/
5959+
#if USE_PARALLEL_SWEEP
5960+
bool do_signal = false;
5961+
sweep_lock_lock(objspace);
5962+
{
5963+
objspace->sweep_rest = true; // reset to false in `gc_sweeping_exit`
5964+
if (!background_sweep_done_p(objspace)) {
5965+
if (objspace->use_background_sweep_thread && !objspace->sweep_thread_sweeping && !objspace->sweep_thread_sweep_requested) {
5966+
do_signal = true;
5967+
objspace->sweep_thread_sweep_requested = true;
5968+
}
5969+
}
5970+
}
5971+
sweep_lock_unlock(objspace);
5972+
if (do_signal) {
5973+
rb_native_cond_signal(&objspace->sweep_cond);
5974+
}
5975+
#endif
59805976
for (int i = 0; i < HEAP_COUNT; i++) {
59815977
rb_heap_t *heap = &heaps[i];
59825978
while (!heap_is_sweep_done(objspace, heap)) {

0 commit comments

Comments
 (0)