Lazier zero_dirty_pages in gencgc
authorPaul Khuong <pvk@pvk.ca>
Sun, 3 Jul 2011 01:52:50 +0000 (21:52 -0400)
committerPaul Khuong <pvk@pvk.ca>
Sun, 3 Jul 2011 01:52:50 +0000 (21:52 -0400)
 Upon allocation, only zero out pages that haven't already been cleared.

src/runtime/gencgc-internal.h
src/runtime/gencgc.c

index cdaa456..84178ad 100644 (file)
@@ -82,7 +82,7 @@ struct page {
          * set. No other objects should be allocated to these pages.
          * This is only valid when the page is allocated. */
         large_object :1,
-        /* True if the page is known to contain only zeroes. */
+        /* Cleared if the page is known to contain only zeroes. */
         need_to_zero :1;
 
     /* the generation that this page belongs to. This should be valid
index 1ea30b4..be5cc4b 100644 (file)
@@ -627,13 +627,13 @@ zero_pages(page_index_t start, page_index_t end) {
  */
 static void
 zero_dirty_pages(page_index_t start, page_index_t end) {
-    page_index_t i;
+    page_index_t i, j;
 
     for (i = start; i <= end; i++) {
-        if (page_table[i].need_to_zero == 1) {
-            zero_pages(start, end);
-            break;
-        }
+        if (!page_table[i].need_to_zero) continue;
+        for (j = i+1; (j <= end) && (page_table[j].need_to_zero); j++);
+        zero_pages(i, j-1);
+        i = j;
     }
 
     for (i = start; i <= end; i++) {