[MLton-commit] r6563
Matthew Fluet
fluet at mlton.org
Mon Apr 7 11:55:47 PDT 2008
Add thread-current-permit-reserved-ratio runtime option.
----------------------------------------------------------------------
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:43 UTC (rev 6562)
+++ mlton/trunk/runtime/gc/controls.h 2008-04-07 18:55:46 UTC (rev 6563)
@@ -33,6 +33,7 @@
float ramSlop;
float threadCurrentGrow;
float threadCurrentMaxReserved;
+ float threadCurrentPermitReserved;
float threadCurrentShrink;
float threadMaxReserved;
float threadShrink;
Modified: mlton/trunk/runtime/gc/forward.c
===================================================================
--- mlton/trunk/runtime/gc/forward.c 2008-04-07 18:55:43 UTC (rev 6562)
+++ mlton/trunk/runtime/gc/forward.c 2008-04-07 18:55:46 UTC (rev 6563)
@@ -71,10 +71,12 @@
/* Shrink active stacks. */
reservedMax =
(size_t)(s->controls.ratios.threadCurrentMaxReserved * stack->used);
+ size_t reservedPermit =
+ (size_t)(s->controls.ratios.threadCurrentPermitReserved * stack->used);
reservedShrink =
- (stack->used <= stack->reserved / 4)
- ? (size_t)(s->controls.ratios.threadCurrentShrink * stack->reserved)
- : stack->reserved;
+ (reservedPermit >= stack->reserved)
+ ? stack->reserved
+ : (size_t)(s->controls.ratios.threadCurrentShrink * stack->used);
reservedMin = sizeofStackMinimumReserved (s, stack);
} else {
/* Shrink paused stacks. */
Modified: mlton/trunk/runtime/gc/init.c
===================================================================
--- mlton/trunk/runtime/gc/init.c 2008-04-07 18:55:43 UTC (rev 6562)
+++ mlton/trunk/runtime/gc/init.c 2008-04-07 18:55:46 UTC (rev 6563)
@@ -205,6 +205,13 @@
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-permit-reserved-ratio")) {
+ i++;
+ if (i == argc)
+ die ("@MLton thread-current-permit-reserved-ratio missing argument.");
+ s->controls.ratios.threadCurrentPermitReserved = stringToFloat (argv[i++]);
+ unless (1.0 < s->controls.ratios.threadCurrentPermitReserved)
+ die ("@MLton thread-current-permit-reserved-ratio argument must greater than 1.0.");
} else if (0 == strcmp (arg, "thread-current-shrink-ratio")) {
i++;
if (i == argc)
@@ -275,6 +282,7 @@
s->controls.ratios.ramSlop = 0.5;
s->controls.ratios.threadCurrentGrow = 2.0;
s->controls.ratios.threadCurrentMaxReserved = 8.0;
+ s->controls.ratios.threadCurrentPermitReserved = 4.0;
s->controls.ratios.threadCurrentShrink = 0.5;
s->controls.ratios.threadMaxReserved = 4.0;
s->controls.ratios.threadShrink = 0.5;
@@ -332,6 +340,9 @@
unless (s->controls.ratios.markCompact <= s->controls.ratios.copy
and s->controls.ratios.copy <= s->controls.ratios.live)
die ("Ratios must satisfy mark-compact-ratio <= copy-ratio <= live-ratio.");
+ unless (s->controls.ratios.threadCurrentPermitReserved
+ <= s->controls.ratios.threadCurrentMaxReserved)
+ die ("Ratios must satisfy thread-current-permit-reserved <= thread-current-max-reserved.");
/* 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.
More information about the MLton-commit
mailing list