[MLton-commit] r5788

Matthew Fluet fluet at mlton.org
Tue Jul 24 21:43:25 PDT 2007


Regularize gc-messages
----------------------------------------------------------------------

U   mlton/trunk/runtime/gc/cheney-copy.c
U   mlton/trunk/runtime/gc/garbage-collection.c
U   mlton/trunk/runtime/gc/heap.c
U   mlton/trunk/runtime/gc/init.c
U   mlton/trunk/runtime/gc/mark-compact.c
U   mlton/trunk/runtime/gc/pack.c
U   mlton/trunk/runtime/gc/translate.c

----------------------------------------------------------------------

Modified: mlton/trunk/runtime/gc/cheney-copy.c
===================================================================
--- mlton/trunk/runtime/gc/cheney-copy.c	2007-07-25 02:58:05 UTC (rev 5787)
+++ mlton/trunk/runtime/gc/cheney-copy.c	2007-07-25 04:43:21 UTC (rev 5788)
@@ -46,6 +46,7 @@
 }
 
 void majorCheneyCopyGC (GC_state s) {
+  size_t bytesCopied;
   struct rusage ru_start;
   pointer toStart;
 
@@ -57,12 +58,11 @@
   s->forwardState.toStart = s->secondaryHeap.start;
   s->forwardState.toLimit = s->secondaryHeap.start + s->secondaryHeap.size;
   if (DEBUG or s->controls.messages) {
-    fprintf (stderr, "Major copying GC.\n");
-    fprintf (stderr, "fromSpace = "FMTPTR" of size %s\n",
-             (uintptr_t) s->heap.start, 
+    fprintf (stderr, "[GC: Major Cheney-copy; from heap at "FMTPTR" of size %s bytes,]\n",
+             (uintptr_t)(s->heap.start), 
              uintmaxToCommaString(s->heap.size));
-    fprintf (stderr, "toSpace = "FMTPTR" of size %s\n",
-             (uintptr_t) s->secondaryHeap.start, 
+    fprintf (stderr, "[GC:                    to heap at "FMTPTR" of size %s bytes.]\n",
+             (uintptr_t)(s->secondaryHeap.start), 
              uintmaxToCommaString(s->secondaryHeap.size));
   }
   assert (s->secondaryHeap.start != (pointer)NULL);
@@ -78,17 +78,16 @@
   foreachObjptrInRange (s, toStart, &s->forwardState.back, forwardObjptr, TRUE);
   updateWeaksForCheneyCopy (s);
   s->secondaryHeap.oldGenSize = s->forwardState.back - s->secondaryHeap.start;
-  s->cumulativeStatistics.bytesCopied += s->secondaryHeap.oldGenSize;
-  if (DEBUG)
-    fprintf (stderr, "%s bytes live.\n",
-             uintmaxToCommaString(s->secondaryHeap.oldGenSize));
+  bytesCopied = s->secondaryHeap.oldGenSize;
+  s->cumulativeStatistics.bytesCopied += bytesCopied;
   swapHeapsForCheneyCopy (s);
   clearCrossMap (s);
   s->lastMajorStatistics.kind = GC_COPYING;
   if (detailedGCTime (s))
     stopTiming (&ru_start, &s->cumulativeStatistics.ru_gcCopy);
   if (DEBUG or s->controls.messages)
-    fprintf (stderr, "Major copying GC done.\n");
+    fprintf (stderr, "[GC: Major Cheney-copy done; %s bytes copied.]\n",
+             uintmaxToCommaString(bytesCopied));
 }
 
 /* ---------------------------------------------------------------- */
@@ -113,13 +112,16 @@
     bytesCopied = 0;
   } else {
     if (DEBUG_GENERATIONAL or s->controls.messages)
-      fprintf (stderr, "Minor copying GC.\n");
+      fprintf (stderr, "[GC: Minor Cheney-copy; nursery at "FMTPTR" of size %s bytes,]\n",
+               (uintptr_t)(s->heap.nursery),
+               uintmaxToCommaString(bytesAllocated));
     if (detailedGCTime (s))
       startTiming (&ru_start);
     s->forwardState.amInMinorGC = TRUE;
     s->forwardState.toStart = s->heap.start + s->heap.oldGenSize;
-    if (DEBUG_GENERATIONAL)
-      fprintf (stderr, "toStart = "FMTPTR"\n", (uintptr_t)s->forwardState.toStart);
+    if (DEBUG_GENERATIONAL or s->controls.messages)
+      fprintf (stderr, "[GC:                    to "FMTPTR".]\n",
+               (uintptr_t)(s->forwardState.toStart));
     assert (isFrontierAligned (s, s->forwardState.toStart));
     s->forwardState.toLimit = s->forwardState.toStart + bytesAllocated;
     assert (invariantForGC (s));
@@ -140,7 +142,7 @@
     if (detailedGCTime (s))
       stopTiming (&ru_start, &s->cumulativeStatistics.ru_gcMinor);
     if (DEBUG_GENERATIONAL or s->controls.messages)
-      fprintf (stderr, "Minor GC done.  %s bytes copied.\n",
+      fprintf (stderr, "[GC: Minor Cheney-copy done; %s bytes copied.]\n",
                uintmaxToCommaString(bytesCopied));
   }
 }

Modified: mlton/trunk/runtime/gc/garbage-collection.c
===================================================================
--- mlton/trunk/runtime/gc/garbage-collection.c	2007-07-25 02:58:05 UTC (rev 5787)
+++ mlton/trunk/runtime/gc/garbage-collection.c	2007-07-25 04:43:21 UTC (rev 5788)
@@ -53,7 +53,7 @@
 
   size = sizeofStackGrow (s, getStackCurrent(s));
   if (DEBUG_STACKS or s->controls.messages)
-    fprintf (stderr, "Growing stack to size %s.\n",
+    fprintf (stderr, "[GC: Growing stack to size %s bytes.]\n",
              uintmaxToCommaString(sizeofStackWithHeaderAligned (s, size)));
   assert (hasHeapBytesFree (s, sizeofStackWithHeaderAligned (s, size), 0));
   stack = newStack (s, size, TRUE);
@@ -97,7 +97,7 @@
 
   enterGC (s);
   if (DEBUG or s->controls.messages)
-    fprintf (stderr, "Starting gc.  Request %s nursery bytes and %s old-gen bytes.\n",
+    fprintf (stderr, "[GC: Starting gc; request %s nursery bytes and %s old-gen bytes.]\n",
              uintmaxToCommaString(nurseryBytesRequested),
              uintmaxToCommaString(oldGenBytesRequested));
   assert (invariantForGC (s));
@@ -130,9 +130,8 @@
   } else
     gcTime = 0;  /* Assign gcTime to quell gcc warning. */
   if (DEBUG or s->controls.messages) {
-    fprintf (stderr, "Finished gc.\n");
-    fprintf (stderr, "time: %s ms\n", uintmaxToCommaString(gcTime));
-    fprintf (stderr, "old gen size: %s bytes (%.1f%%)\n", 
+    fprintf (stderr, "[GC: Finished gc; time: %s ms, old-gen: %s bytes (%.1f%%).]\n",
+             uintmaxToCommaString(gcTime),
              uintmaxToCommaString(s->heap.oldGenSize),
              100.0 * ((double)(s->heap.oldGenSize) 
                       / (double)(s->heap.size)));
@@ -178,7 +177,7 @@
 
 void GC_collect (GC_state s, size_t bytesRequested, bool force,
             char *file, int line) {
-  if (DEBUG or s->controls.messages)
+  if (DEBUG)
     fprintf (stderr, "%s %d: GC_collect\n", file, line);
   enter (s);
   /* When the mutator requests zero bytes, it may actually need as

Modified: mlton/trunk/runtime/gc/heap.c
===================================================================
--- mlton/trunk/runtime/gc/heap.c	2007-07-25 02:58:05 UTC (rev 5787)
+++ mlton/trunk/runtime/gc/heap.c	2007-07-25 04:43:21 UTC (rev 5788)
@@ -110,8 +110,8 @@
   if (NULL == h->start)
     return;
   if (DEBUG or s->controls.messages)
-    fprintf (stderr, "Releasing heap at "FMTPTR" of size %s.\n",
-             (uintptr_t)h->start,
+    fprintf (stderr, "[GC: Releasing heap at "FMTPTR" of size %s bytes.]\n",
+             (uintptr_t)(h->start),
              uintmaxToCommaString(h->size));
   GC_release (h->start, h->size);
   initHeap (s, h);
@@ -127,8 +127,8 @@
   if (keep < h->size) {
     if (DEBUG or s->controls.messages)
       fprintf (stderr,
-               "Shrinking heap at "FMTPTR" of size %s to %s bytes.\n",
-               (uintptr_t)h->start,
+               "[GC: Shrinking heap at "FMTPTR" of size %s bytes to size %s bytes.]\n",
+               (uintptr_t)(h->start),
                uintmaxToCommaString(h->size),
                uintmaxToCommaString(keep));
     GC_decommit (h->start + keep, h->size - keep);
@@ -190,17 +190,17 @@
         if (h->size > s->cumulativeStatistics.maxHeapSizeSeen)
           s->cumulativeStatistics.maxHeapSizeSeen = h->size;
         if (DEBUG or s->controls.messages)
-          fprintf (stderr, "Created heap of size %s at "FMTPTR".\n",
-                   uintmaxToCommaString(h->size),
-                   (uintptr_t)h->start);
+          fprintf (stderr, "[GC: Created heap at "FMTPTR" of size %s bytes.]\n",
+                   (uintptr_t)(h->start),
+                   uintmaxToCommaString(h->size));
         assert (h->size >= minSize);
         return TRUE;
       }
     }
     if (s->controls.messages)
       fprintf(stderr, 
-              "[Requested %s cannot be satisfied, "
-              "backing off by %s (min size = %s).]\n",
+              "[GC: Creating heap of size %s bytes cannot be satisfied; "
+              "backing off by %s bytes (min size = %s).]\n",
               sizeToBytesApproxString (h->size),
               sizeToBytesApproxString (backoff), 
               sizeToBytesApproxString (minSize));

Modified: mlton/trunk/runtime/gc/init.c
===================================================================
--- mlton/trunk/runtime/gc/init.c	2007-07-25 02:58:05 UTC (rev 5787)
+++ mlton/trunk/runtime/gc/init.c	2007-07-25 04:43:21 UTC (rev 5788)
@@ -307,7 +307,7 @@
   s->sysvals.ram = align ((size_t)(s->controls.ratios.ramSlop * s->sysvals.totalRam), 
                           s->sysvals.pageSize);
   if (DEBUG or DEBUG_RESIZING or s->controls.messages)
-    fprintf (stderr, "total RAM = %s  RAM = %s\n",
+    fprintf (stderr, "[GC: total RAM = %s, using RAM = %s.]\n",
              uintmaxToCommaString(s->sysvals.totalRam),
              uintmaxToCommaString(s->sysvals.ram));
   if (DEBUG_SOURCES or DEBUG_PROFILE) {

Modified: mlton/trunk/runtime/gc/mark-compact.c
===================================================================
--- mlton/trunk/runtime/gc/mark-compact.c	2007-07-25 02:58:05 UTC (rev 5787)
+++ mlton/trunk/runtime/gc/mark-compact.c	2007-07-25 04:43:21 UTC (rev 5788)
@@ -277,15 +277,15 @@
 }
 
 void majorMarkCompactGC (GC_state s) {
+  size_t bytesMarkCompacted;
   struct rusage ru_start;
 
   if (detailedGCTime (s))
     startTiming (&ru_start);
   s->cumulativeStatistics.numMarkCompactGCs++;
   if (DEBUG or s->controls.messages) {
-    fprintf (stderr, "Major mark-compact GC.\n");
-    fprintf (stderr, "heap = "FMTPTR" of size %s\n",
-             (uintptr_t) s->heap.start, 
+    fprintf (stderr, "[GC: Major mark-compact; heap at "FMTPTR" of size %s bytes.]\n",
+             (uintptr_t)(s->heap.start), 
              uintmaxToCommaString(s->heap.size));
   }
   if (s->hashConsDuringGC) {
@@ -301,12 +301,14 @@
   updateForwardPointersForMarkCompact (s);
   updateBackwardPointersAndSlideForMarkCompact (s);
   clearCrossMap (s);
-  s->cumulativeStatistics.bytesMarkCompacted += s->heap.oldGenSize;
+  bytesMarkCompacted = s->heap.oldGenSize;
+  s->cumulativeStatistics.bytesMarkCompacted += bytesMarkCompacted;
   s->lastMajorStatistics.kind = GC_MARK_COMPACT;
   if (detailedGCTime (s))
     stopTiming (&ru_start, &s->cumulativeStatistics.ru_gcMarkCompact);
   if (DEBUG or s->controls.messages) {
-    fprintf (stderr, "Major mark-compact GC done.\n");
+    fprintf (stderr, "[GC: Major mark-compact done; %s bytes mark compacted.]\n",
+             uintmaxToCommaString(bytesMarkCompacted));
     if (s->hashConsDuringGC)
       printBytesHashConsedMessage(s, 
                                   s->lastMajorStatistics.bytesHashConsed 

Modified: mlton/trunk/runtime/gc/pack.c
===================================================================
--- mlton/trunk/runtime/gc/pack.c	2007-07-25 02:58:05 UTC (rev 5787)
+++ mlton/trunk/runtime/gc/pack.c	2007-07-25 04:43:21 UTC (rev 5788)
@@ -11,7 +11,8 @@
 
   enter (s);
   if (DEBUG or s->controls.messages)
-    fprintf (stderr, "Packing heap of size %s.\n",
+    fprintf (stderr, "[GC: Packing heap at "FMTPTR" of size %s bytes.]\n",
+             (uintptr_t)(s->heap.start),
              uintmaxToCommaString(s->heap.size));
   /* Could put some code here to skip the GC if there hasn't been much
    * allocated since the last collection.  But you would still need to
@@ -26,7 +27,8 @@
   }
   releaseHeap (s, &s->secondaryHeap);
   if (DEBUG or s->controls.messages)
-    fprintf (stderr, "Packed heap to size %s.\n",
+    fprintf (stderr, "[GC: Packed heap at "FMTPTR" to size %s bytes.]\n",
+             (uintptr_t)(s->heap.start),
              uintmaxToCommaString(s->heap.size));
   leave (s);
 }
@@ -34,7 +36,8 @@
 void GC_unpack (GC_state s) {
   enter (s);
   if (DEBUG or s->controls.messages)
-    fprintf (stderr, "Unpacking heap of size %s.\n",
+    fprintf (stderr, "[GC: Unpacking heap at "FMTPTR" of size %s bytes.]\n", 
+             (uintptr_t)(s->heap.start),
              uintmaxToCommaString(s->heap.size));
   /* The enterGC is needed here because minorGC and resizeHeap might
    * move the stack, and the SIGPROF catcher would then see a bogus
@@ -48,7 +51,8 @@
   setGCStateCurrentThreadAndStack (s);
   leaveGC (s);
   if (DEBUG or s->controls.messages)
-    fprintf (stderr, "Unpacked heap to size %s.\n",
+    fprintf (stderr, "[GC: Unpacked heap at "FMTPTR" to size %s bytes.]\n",
+             (uintptr_t)(s->heap.start),
              uintmaxToCommaString(s->heap.size));
   leave (s);
 }

Modified: mlton/trunk/runtime/gc/translate.c
===================================================================
--- mlton/trunk/runtime/gc/translate.c	2007-07-25 02:58:05 UTC (rev 5787)
+++ mlton/trunk/runtime/gc/translate.c	2007-07-25 04:43:21 UTC (rev 5788)
@@ -31,9 +31,10 @@
   pointer limit;
 
   if (DEBUG or s->controls.messages)
-    fprintf (stderr, "Translating heap of size %s from "FMTPTR" to "FMTPTR".\n",
+    fprintf (stderr, "[GC: Translating heap at "FMTPTR" of size %s bytes to "FMTPTR".]\n",
+             (uintptr_t)from,
              uintmaxToCommaString(size),
-             (uintptr_t)from, (uintptr_t)to);
+             (uintptr_t)to);
   if (from == to)
     return;
   else {




More information about the MLton-commit mailing list