@@ -5437,6 +5437,10 @@ gc_sweep_start(rb_objspace_t *objspace)
54375437 bool do_signal = false;
54385438 if (objspace -> sweep_thread &&
54395439 !objspace -> flags .during_compacting &&
5440+ /* A major immediate GC sweeps the rest synchronously (gc_sweep_rest)
5441+ * right after this, so handing work to the background thread only adds
5442+ * lock contention with no chance to overlap. Keep it on the FG. */
5443+ !(is_full_marking (objspace ) && objspace -> flags .immediate_sweep ) &&
54405444 !(objspace -> hook_events & RUBY_INTERNAL_EVENT_FREEOBJ )) {
54415445 psweep_debug (-1 , "[gc] gc_sweep_start: requesting sweep thread\n" );
54425446 objspace -> use_background_sweep_thread = true;
@@ -5962,23 +5966,23 @@ background_sweep_done_p(rb_objspace_t *objspace)
59625966static void
59635967gc_sweep_rest (rb_objspace_t * objspace )
59645968{
5965- #if USE_PARALLEL_SWEEP
5966- bool do_signal = false;
5967- sweep_lock_lock (objspace );
5968- {
5969- objspace -> sweep_rest = true; // reset to false in `gc_sweeping_exit`
5970- if (!background_sweep_done_p (objspace )) {
5971- if (objspace -> use_background_sweep_thread && !objspace -> sweep_thread_sweeping && !objspace -> sweep_thread_sweep_requested ) {
5972- do_signal = true;
5973- objspace -> sweep_thread_sweep_requested = true;
5974- }
5975- }
5976- }
5977- sweep_lock_unlock (objspace );
5978- if (do_signal ) {
5979- rb_native_cond_signal (& objspace -> sweep_cond );
5980- }
5981- #endif
5969+ /* #if USE_PARALLEL_SWEEP*/
5970+ /* bool do_signal = false;*/
5971+ /* sweep_lock_lock(objspace);*/
5972+ /*{*/
5973+ /* objspace->sweep_rest = true; // reset to false in `gc_sweeping_exit`*/
5974+ /* if (!background_sweep_done_p(objspace)) {*/
5975+ /* if (objspace->use_background_sweep_thread && !objspace->sweep_thread_sweeping && !objspace->sweep_thread_sweep_requested) {*/
5976+ /* do_signal = true;*/
5977+ /* objspace->sweep_thread_sweep_requested = true;*/
5978+ /*}*/
5979+ /*}*/
5980+ /*}*/
5981+ /* sweep_lock_unlock(objspace);*/
5982+ /* if (do_signal) {*/
5983+ /* rb_native_cond_signal(&objspace->sweep_cond);*/
5984+ /*}*/
5985+ /* #endif*/
59825986 for (int i = 0 ; i < HEAP_COUNT ; i ++ ) {
59835987 rb_heap_t * heap = & heaps [i ];
59845988 while (!heap_is_sweep_done (objspace , heap )) {
0 commit comments