[MLton] callcc and space use
Florian Weimer
fweimer at bfk.de
Wed Jan 23 00:37:35 PST 2008
* Vesa Karvonen:
> Just curious, since you specifically mention using callcc to suspend
> and resume computation (rather than to fork computation), I wonder
> whether there is a reason to use MLton's callcc
> (http://mlton.org/MLtonCont) rather than MLton's threads
> (http://mlton.org/MLtonThread), which are expressive enough for
> suspending and resuming computation. I ask about this, because,
> AFAIK, MLton's callcc and throw are implemented on top of MLton's
> threads by copying the stack and performing thread switches. IOW,
> using just MLton's threads (i.e. switch) for suspend and resume would
> likely be considerably more efficient.
I think it's the other way round. But new threads are copied from a
specific thread with an empty stack, which is faster than copying the
current thread's stack. However, the function to call is passed to
the nascent thread in a global variable (with suitable locking), and
this results in unnecessary contention in a parallel environment.
It seems that there is some room for improvement here.
--
Florian Weimer <fweimer at bfk.de>
BFK edv-consulting GmbH http://www.bfk.de/
Kriegsstraße 100 tel: +49-721-96201-1
D-76133 Karlsruhe fax: +49-721-96201-99
More information about the MLton
mailing list