[MLton-devel] cvs commit: generationalRatio

Stephen Weeks sweeks@users.sourceforge.net
Thu, 19 Sep 2002 11:49:22 -0700


sweeks      02/09/19 11:49:22

  Modified:    runtime  gc.c gc.h
  Log:
  Split generationalRatio into two constants, copyGenerationalRatio and
  markCompactGenerationalRatio, which are used depending on the current GC
  strategy.

Revision  Changes    Path
1.95      +18 -5     mlton/runtime/gc.c

Index: gc.c
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/gc.c,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -r1.94 -r1.95
--- gc.c	19 Sep 2002 06:53:47 -0000	1.94
+++ gc.c	19 Sep 2002 18:49:22 -0000	1.95
@@ -1205,7 +1205,9 @@
 		 * worthwhile.
 		 */
 		and (float)h->size / (float)s->bytesLive 
-			<= s->generationalRatio
+			<= (h->size < s->ram
+				? s->copyGenerationalRatio
+				: s->markCompactGenerationalRatio)
 		/* The nursery is large enough to be worth it. */
 		and ((float)(h->size - s->bytesLive) 
 			/ (float)s->nurserySize) <= s->nurseryRatio
@@ -3149,13 +3151,14 @@
 	s->canHandle = 0;
 	s->cardSize = 0x1 << s->cardSizeLog2;
 	s->copyRatio = 4.0;
+	s->copyGenerationalRatio = 4.0;
 	s->currentThread = BOGUS_THREAD;
-	s->generationalRatio = 5.0;
 	s->growRatio = 8.0;
 	s->inSignalHandler = FALSE;
 	s->isOriginal = TRUE;
 	s->liveRatio = 8.0;
 	s->markCompactRatio = 1.04;
+	s->markCompactGenerationalRatio = 8.0;
 	s->markedCards = 0;
 	s->maxBytesLive = 0;
 	s->maxHeap = 0;
@@ -3226,11 +3229,11 @@
 				} else if (0 == strcmp (arg, "gc-summary")) {
 					++i;
 					s->summary = TRUE;
-				} else if (0 == strcmp (arg, "generational-ratio")) {
+				} else if (0 == strcmp (arg, "copy-generational-ratio")) {
 					++i;
 					if (i == argc)
 						usage (argv[0]);
-					s->generationalRatio =
+					s->copyGenerationalRatio =
 						stringToFloat (argv[i++]);
 				} else if (0 == strcmp (arg, "grow-ratio")) {
 					++i;
@@ -3256,6 +3259,12 @@
 						usage (argv[0]);
 					s->useFixedHeap = FALSE;
 					s->maxHeap = stringToBytes (argv[i++]);
+				} else if (0 == strcmp (arg, "mark-compact-generational-ratio")) {
+					++i;
+					if (i == argc)
+						usage (argv[0]);
+					s->markCompactGenerationalRatio =
+						stringToFloat (argv[i++]);
 				} else if (0 == strcmp (arg, "mark-compact-ratio")) {
 					++i;
 					if (i == argc)
@@ -3286,7 +3295,11 @@
 	unless (ratiosOk (s))
 		die ("invalid ratios");
 	setMemInfo (s);
-	s->ram = s->ramSlop * s->totalRam;
+	/* We align s->ram by pageSize so that we can test whether or not we
+	 * we are using mark-compact by comparing heap size to ram size.  If 
+	 * we didn't round, the size might be slightly off.
+         */
+	s->ram = align (s->ramSlop * s->totalRam, s->pageSize);
 	if (DEBUG or DEBUG_RESIZING or s->messages)
 		fprintf (stderr, "totalRam = %s  totalSwap = %s  ram = %s\n",
 				uintToCommaString (s->totalRam), 



1.43      +8 -3      mlton/runtime/gc.h

Index: gc.h
===================================================================
RCS file: /cvsroot/mlton/mlton/runtime/gc.h,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- gc.h	24 Aug 2002 22:24:07 -0000	1.42
+++ gc.h	19 Sep 2002 18:49:22 -0000	1.43
@@ -242,6 +242,10 @@
 	uint cardMapSize;
 	uint cardSize;
 	uint cardSizeLog2;
+	/* Only use generational GC with copying collection if the ratio of 
+ 	 * semispace size to live data size is below copyGenerationalRatio.
+	 */
+	float copyGenerationalRatio;
 	float copyRatio;	/* Minimum live ratio to use copying GC. */
 	GC_heap crossMapHeap;	/* only used during GC. */
 	pointer crossMap;
@@ -249,9 +253,6 @@
 	GC_thread currentThread; /* This points to a thread in the heap. */
 	uint fixedHeapSize; 	/* Only meaningful if useFixedHeap. */
 	GC_frameLayout *frameLayouts;
-	/* Only use generational GC if the live ratio is below generationalRatio.
-	 */
-	float generationalRatio;
 	pointer *globals; 	/* An array of size numGlobals. */
 	float growRatio;
 	struct GC_heap heap;
@@ -271,6 +272,10 @@
 	/* Minimum live ratio to us mark-compact GC. */
 	float markCompactRatio; 
 	ullong markedCards; /* Number of marked cards seen during minor GCs. */
+	/* Only use generational GC with mark-compact collection if the ratio of 
+ 	 * heap size to live data size is below markCompactGenerationalRatio.
+	 */
+	float markCompactGenerationalRatio;
 	uint maxBytesLive;
 	uint maxFrameIndex; /* 0 <= frameIndex < maxFrameIndex */
 	uint maxFrameSize;





-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel