From 49780c2e25cfbe821d585c5a31cb95aa49f41f14 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Wed, 16 Apr 2008 23:28:25 +0000 Subject: [PATCH] rearrange: we were calling markSomeCapabilities too often --- rts/sm/GC.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/rts/sm/GC.c b/rts/sm/GC.c index b381e56..978b7a0 100644 --- a/rts/sm/GC.c +++ b/rts/sm/GC.c @@ -144,7 +144,7 @@ static void update_task_list (void); static void resize_generations (void); static void resize_nursery (void); static void start_gc_threads (void); -static void gc_thread_work (void); +static void scavenge_until_all_done (void); static nat inc_running (void); static nat dec_running (void); static void wakeup_gc_threads (nat n_threads); @@ -350,7 +350,7 @@ GarbageCollect ( rtsBool force_major_gc ) */ for (;;) { - gc_thread_work(); + scavenge_until_all_done(); // The other threads are now stopped. We might recurse back to // here, but from now on this is the only thread. @@ -883,26 +883,13 @@ dec_running (void) return n_running; } -// -// gc_thread_work(): Scavenge until there's no work left to do and all -// the running threads are idle. -// static void -gc_thread_work (void) +scavenge_until_all_done (void) { nat r; debugTrace(DEBUG_gc, "GC thread %d working", gct->thread_index); - // gc_running_threads has already been incremented for us; either - // this is the main thread and we incremented it inside - // GarbageCollect(), or this is a worker thread and the main - // thread bumped gc_running_threads before waking us up. - - // Every thread evacuates some roots. - gct->evac_step = 0; - markSomeCapabilities(mark_root, gct, gct->thread_index, n_gc_threads); - loop: scavenge_loop(); // scavenge_loop() only exits when there's no work to do @@ -927,8 +914,26 @@ loop: debugTrace(DEBUG_gc, "GC thread %d finished.", gct->thread_index); } - #if defined(THREADED_RTS) +// +// gc_thread_work(): Scavenge until there's no work left to do and all +// the running threads are idle. +// +static void +gc_thread_work (void) +{ + // gc_running_threads has already been incremented for us; this is + // a worker thread and the main thread bumped gc_running_threads + // before waking us up. + + // Every thread evacuates some roots. + gct->evac_step = 0; + markSomeCapabilities(mark_root, gct, gct->thread_index, n_gc_threads); + + scavenge_until_all_done(); +} + + static void gc_thread_mainloop (void) { -- 1.7.10.4