[commit: ghc] ghc-7.10: Optimise scavenge_large_srt_bitmap (a7060f9)

git at git.haskell.org git at git.haskell.org
Wed Jan 14 12:53:05 UTC 2015


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-7.10
Link       : http://ghc.haskell.org/trac/ghc/changeset/a7060f9946379f49dc906ba67a88f359cee44ca9/ghc

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

commit a7060f9946379f49dc906ba67a88f359cee44ca9
Author: Simon Marlow <marlowsd at gmail.com>
Date:   Tue Jan 13 20:33:20 2015 +0000

    Optimise scavenge_large_srt_bitmap
    
    Very large modules can sometimes contain very large SRT bitmaps (this
    is a separate problem that I need to look into).  The large bitmaps
    often contain a lot of zeros, so this patch skips over empty words in
    the bitmap.
    
    It makes a dramatic difference in the particular example that I saw,
    where an old gen GC was taking 0.5s before this change and 0.07s after
    it.
    
    (cherry picked from commit cf8e669ba622fade18f9977aa374fda25cb078e6)


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

a7060f9946379f49dc906ba67a88f359cee44ca9
 rts/sm/Scav.c | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/rts/sm/Scav.c b/rts/sm/Scav.c
index 97c6589..2ecb23b 100644
--- a/rts/sm/Scav.c
+++ b/rts/sm/Scav.c
@@ -276,24 +276,34 @@ scavenge_AP (StgAP *ap)
 static void
 scavenge_large_srt_bitmap( StgLargeSRT *large_srt )
 {
-    nat i, b, size;
+    nat i, j, size;
     StgWord bitmap;
     StgClosure **p;
 
-    b = 0;
-    bitmap = large_srt->l.bitmap[b];
     size   = (nat)large_srt->l.size;
     p      = (StgClosure **)large_srt->srt;
-    for (i = 0; i < size; ) {
-        if ((bitmap & 1) != 0) {
-            evacuate(p);
-        }
-        i++;
-        p++;
-        if (i % BITS_IN(W_) == 0) {
-            b++;
-            bitmap = large_srt->l.bitmap[b];
+
+    for (i = 0; i < size / BITS_IN(W_); i++) {
+        bitmap = large_srt->l.bitmap[i];
+        if (bitmap != 0) {
+            for (j = 0; j < BITS_IN(W_); j++) {
+                if ((bitmap & 1) != 0) {
+                    evacuate(p);
+                }
+                p++;
+                bitmap = bitmap >> 1;
+            }
         } else {
+            p += BITS_IN(W_);
+        }
+    }
+    if (size % BITS_IN(W_) != 0) {
+        bitmap = large_srt->l.bitmap[i];
+        for (j = 0; j < size % BITS_IN(W_); j++) {
+            if ((bitmap & 1) != 0) {
+                evacuate(p);
+            }
+            p++;
             bitmap = bitmap >> 1;
         }
     }



More information about the ghc-commits mailing list