
On 11 October 2004 05:37, Serge D. Mechveliani wrote:
I am not sure but have such an impression that the -K option (for the stack size) appears and disappears between the GHC versions.
Nope, the -K option has always been there.
ghc-6.2.2-September-26 requires -K to be set independently of -M (when the stack is exhausted).
Is not this more nice and flexible to take from the given memory as much stack as it is needed, without asking the user?
We have a default limit on the stack size because it's very easy in Haskell to write a program with an infinite loop that eats up all your memory. On some systems, eating up all the memory can lead to severe consequences (random processing getting terminated, etc.). A while back we removed the default limit on the heap size, because many people felt that the benefit of not having to explicitly increase the heap size was worth the potential pain of a space leak using up all the memory. In retrospect, I think that was probably the right choice, although I argued against it at the time. Nowadays platforms have per-process or per-user memory limits, and are generally more robust in low-memory situations. So, perhaps we should set the default stack size to be unlimited. I'm prepared to be persuaded. Anyway, to answer your question: yes, I think it would make sense when the user has specified -M for the stack size to be limited only by the maximum heap size given with the -M option. But, this would be an extra thing to document with the -M option, and you can already get this behaviour by saying -M<size> -K<size>.
It is natural for the user think of some abstract Haskell machine which performs the program in the given memory size (-M..). Whether the given memory is divided to `stack' and other parts -- this is a technical detail, an internal matter of implementation, and the user need not to know about stack.
That is already the case.
On the other hand, the final report of kind "xxx bytes used for stack" is helpful (in profiling?), for it helps to detect the unneeded `laziness' cases and such.
You can see the stack size when profiling with the -xt option. Cheers, Simon