[MLton] Re: [Haskell-cafe] fastest Fibonacci numbers in the West

Wesley W. Terpstra wesley@terpstra.ca
Thu, 27 Jan 2005 20:17:33 +0100


On Thu, Jan 27, 2005 at 01:56:47PM -0500, Matthew Fluet wrote:
> A: GMP allocates most temporaries on the stack, and some machines give
> user programs very little stack space by default. See setrlimit(2) for
> information on how to increase the stack allocation. You can also change
> it from the shell (using ulimit or limit depending on the shell). You can
> also configure with --disable-alloca to instead allocate temporaries using
> malloc, but that will make the library run somewhat slower.

Confirmed.

terpstra@carrot:~$ ulimit -s 81920
terpstra@carrot:~$ time ./fib 99999999 > out
real    3m18.830s
user    3m17.097s
sys     0m1.719s
terpstra@carrot:~$ v out
-rw-rw-r--  1 terpstra terpstra 20898765 Jan 27 20:11 out

... well that sucks. It also appears that setrlimit cannot increase a limit,
so MLton's main() can't fix the issue short of making a new C call stack.

I thought MLton used its own stack anyways? I have certainly written code in
MLton that would overflow the mere 8MB stack that my system defaults to.

-- 
Wesley W. Terpstra