[MLton] thread stacks

Stephen Weeks MLton@mlton.org
Tue, 5 Apr 2005 13:14:13 -0700

> Is there an easy way to varry the stack size of a prim.thread?

Not from SML code.  The only thing exposed by the runtime system,
although not officially documented, is

	@MLton thread-shrink-ratio <x> --

which is used during a gc, when 0 <= x <= 1 is multiplied by the
current stack size for inactive stacks to determine how much they are
shrunk by.

Other than that, all stack sizing is handled by the runtime.  When you
initially create a thread, via GC_copyCurrentThread, the new thread's
size is the same as the current thread.  For whatever thread is
running, its stack size doubles as needed whenever it runs out of
stack space.  It's easy to tweak the factor of two for growth by
modifying a hardwired constant in gc.c.