profiling for stack usage
Simon Marlow
simonmar@microsoft.com
Fri, 15 Aug 2003 12:37:15 +0100
> I'm currently in a situation where my program runs easily out of
> stack. Depending on the input, stack usage often exceeds 10Mb.
>
> 1. Is there a way to profile stack usage, so that I can identify the
> culprit and deal with the problem at the root? Normal (time)
> profiling tells me how many times a function is called, but it would
> be interesting to know how many times it was recursively called, or
> the size of its stack frames. Is that information available?
>
> Heap profiling -- well, it doesn't *sound* as if it would incorporate
> the stack; does it anyway?
See:
http://www.haskell.org/ghc/docs/latest/html/users_guide/prof-heap.html#RTS-OPTIONS-HEAP-PROF+RTS
in particular, the -xt flag.
> 2. Is there a way to compile programs to use more than the default
> stack? I can of course pass +RTS -K10M -RTS on the command line, but
> I would rather like to change the default, instead of kicking myself
> for forgetting it all the time. And is there any reason (except
> excessive resource consumption and postponed failure from infinite
> loops) not to run with huge stacks?
See:
http://www.haskell.org/ghc/docs/latest/html/users_guide/runtime-control.html#RTS-HOOKS
Cheers,
Simon "the only reason I write docs is so I can say RTFM" Marlow