[commit: ghc] master: Small parallel GC improvement (027a654)

Simon Marlow <[email protected]>
Newsgroups gmane.comp.lang.haskell.cvs.ghc
Message-ID <[email protected]>
Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/027a654c2003569a6fb74f86a9548101ecd1ffa9

>---------------------------------------------------------------

commit 027a654c2003569a6fb74f86a9548101ecd1ffa9
Author: Simon Marlow <[email protected]>
Date:   Fri Sep 7 17:01:24 2012 +0100

    Small parallel GC improvement
    
    Overlap the main thread's clearNursery() with the other threads.

>---------------------------------------------------------------

 rts/sm/GC.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/rts/sm/GC.c b/rts/sm/GC.c
index 7bdaef5..9360645 100644
--- a/rts/sm/GC.c
+++ b/rts/sm/GC.c
@@ -404,6 +404,10 @@ GarbageCollect (nat collect_gen,
       break;
   }
 
+  if (n_gc_threads != 1) {
+      gct->allocated = clearNursery(cap);
+  }
+
   shutdown_gc_threads(gct->thread_index);
 
   // Now see which stable names are still alive.
@@ -636,9 +640,15 @@ GarbageCollect (nat collect_gen,
           allocated += clearNursery(&capabilities[n]);
       }
   } else {
-      gct->allocated = clearNursery(cap);
+      // When doing parallel GC, clearNursery() is called by the
+      // worker threads, and the value returned is stored in
+      // gct->allocated.
       for (n = 0; n < n_capabilities; n++) {
-          allocated += gc_threads[n]->allocated;
+          if (gc_threads[n]->idle) {
+              allocated += clearNursery(&capabilities[n]);
+          } else {
+              allocated += gc_threads[n]->allocated;
+          }
       }
   }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.