[MLton] callcc and space use

Vesa Karvonen vesa.a.j.k at gmail.com
Wed Feb 20 12:15:12 PST 2008


On Thu, Feb 14, 2008 at 5:09 PM, Matthew Fluet <fluet at tti-c.org> wrote:
[...]
>  There was a (short) discussion of stack resizing policy a few years ago:
>    http://mlton.org/pipermail/mlton/2004-April/025297.html
>
>  I suspect that it will be difficult to have a one-size-fits-all policy.
>  When shrinking is too aggressive, you pay to grow the stack when a stack
>  is resumed.  When shrinking isn't aggressive enough, you pay in space and
>  GC time for the wasted space.  If you have a small number of preemptively
>  scheduled threads, then no thread is idle for too long, and it makes more
>  sense to not resize stacks too aggressively.  If you have a large number
>  of idle threads, then it makes sense to resize the stacks more
>  aggressively.

Sounds reasonable, but, even if it might not be optimal for all cases,
I think that it would be least surprising to have a default resizing
policy that ensures that the reserved stack space is not more than a
constant factor of the used space.  Otherwise it would not be
difficult to construct programs that appear to have a space leak.

>  On the other hand, your policy of requiring a paused stack to have have
>  reserved <= 4 * used seems reasonable.  But, with that policy, does it
>  matter whether there is the additional policy that we halve the reserved
>  size each time a paused thread lives through a GC?

I think that just a hard limit of 4*used wouldn't be enough, because
then long lived paused threads would never be minimized.

>  BTW, I also noticed that the stack resizing policy is only in effect for a
>  copying GC (minor or major).  The mark-compact GC will not resize paused
>  stacks, though I don't see why I couldn't.

I think it would be least surprising to resize paused stacks in either case.

-Vesa Karvonen



More information about the MLton mailing list