[commit: ghc] master: Optimise scavenge_large_srt_bitmap (cf8e669)

git at git.haskell.org git at git.haskell.org
Tue Jan 13 23:00:14 UTC 2015


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/cf8e669ba622fade18f9977aa374fda25cb078e6/ghc

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

commit cf8e669ba622fade18f9977aa374fda25cb078e6
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.


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

cf8e669ba622fade18f9977aa374fda25cb078e6
 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