[MLton-commit] r6558

Matthew Fluet fluet at mlton.org
Mon Apr 7 11:55:33 PDT 2008


Add thread-current-shrink-ratio and thread-current-max-reserved-ratio
runtime options.

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

U   mlton/trunk/runtime/gc/controls.h
U   mlton/trunk/runtime/gc/forward.c
U   mlton/trunk/runtime/gc/init.c

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

Modified: mlton/trunk/runtime/gc/controls.h
===================================================================
--- mlton/trunk/runtime/gc/controls.h	2008-04-07 18:55:30 UTC (rev 6557)
+++ mlton/trunk/runtime/gc/controls.h	2008-04-07 18:55:33 UTC (rev 6558)
@@ -32,6 +32,8 @@
   float nursery; 
   float ramSlop;
   float threadCurrentGrow;
+  float threadCurrentMaxReserved;
+  float threadCurrentShrink;
   float threadMaxReserved;
   float threadShrink;
 };

Modified: mlton/trunk/runtime/gc/forward.c
===================================================================
--- mlton/trunk/runtime/gc/forward.c	2008-04-07 18:55:30 UTC (rev 6557)
+++ mlton/trunk/runtime/gc/forward.c	2008-04-07 18:55:33 UTC (rev 6558)
@@ -70,12 +70,15 @@
          * but don't violate the stack invariant.
          */
         if (stack->used <= stack->reserved / 4) {
-          size_t reservedShrink = stack->reserved / 2;
+          size_t reservedMax =
+            (size_t)(s->controls.ratios.threadCurrentMaxReserved * stack->used);
+          size_t reservedShrink =
+            (size_t)(s->controls.ratios.threadCurrentShrink * stack->reserved);
           size_t reservedMin =
             sizeofStackMinimumReserved (s, stack);
           size_t reservedNew =
             alignStackReserved
-            (s, max(reservedShrink,reservedMin));
+            (s, max(min(reservedMax,reservedShrink),reservedMin));
           /* It's possible that new > stack->reserved if the stack
            * invariant is violated. In that case, we want to leave the
            * stack alone, because some other part of the gc will grow

Modified: mlton/trunk/runtime/gc/init.c
===================================================================
--- mlton/trunk/runtime/gc/init.c	2008-04-07 18:55:30 UTC (rev 6557)
+++ mlton/trunk/runtime/gc/init.c	2008-04-07 18:55:33 UTC (rev 6558)
@@ -198,6 +198,20 @@
           s->controls.ratios.threadCurrentGrow = stringToFloat (argv[i++]);
           unless (1.0 < s->controls.ratios.threadCurrentGrow)
             die ("@MLton thread-current-grow-ratio argument must greater than 1.0.");
+        } else if (0 == strcmp (arg, "thread-current-max-reserved-ratio")) {
+          i++;
+          if (i == argc)
+            die ("@MLton thread-current-max-reserved-ratio missing argument.");
+          s->controls.ratios.threadCurrentMaxReserved = stringToFloat (argv[i++]);
+          unless (1.0 < s->controls.ratios.threadCurrentMaxReserved)
+            die ("@MLton thread-current-max-reserved-ratio argument must greater than 1.0.");
+        } else if (0 == strcmp (arg, "thread-current-shrink-ratio")) {
+          i++;
+          if (i == argc)
+            die ("@MLton thread-current-shrink-ratio missing argument.");
+          s->controls.ratios.threadCurrentShrink = stringToFloat (argv[i++]);
+          unless (1.0 < s->controls.ratios.threadCurrentShrink)
+            die ("@MLton thread-current-shrink-ratio argument must be between 0.0 and 1.0.");
         } else if (0 == strcmp (arg, "thread-max-reserved-ratio")) {
           i++;
           if (i == argc)
@@ -260,6 +274,8 @@
   s->controls.ratios.nursery = 10.0;
   s->controls.ratios.ramSlop = 0.5;
   s->controls.ratios.threadCurrentGrow = 2.0;
+  s->controls.ratios.threadCurrentMaxReserved = 8.0;
+  s->controls.ratios.threadCurrentShrink = 0.5;
   s->controls.ratios.threadMaxReserved = 4.0;
   s->controls.ratios.threadShrink = 0.5;
   s->controls.summary = FALSE;




More information about the MLton-commit mailing list