[Haskell-cafe] cap 3: stopping thread 3 (stackoverflow)

David Peixotto dmp at rice.edu
Tue Jun 7 18:11:12 CEST 2011


GHC starts threads with a small stack size to efficiently support lightweight concurrency. As a thread uses more stack space, it will be expanded as needed up to some maximum fixed size. I think these stack overflow events you see are the runtime expanding the thread stacks. 

You can adjust the initial and maximum stack sizes using the -k (initial) and -K (max) RTS options.

Quoting from the GHC users guide (http://www.haskell.org/ghc/docs/7.0-latest/html/users_guide/runtime-control.html#setting-rts-options):

-ksize
[Default: 1k] Set the initial stack size for new threads. Thread stacks (including the main thread's stack) live on the heap, and grow as required. The default value is good for concurrent applications with lots of small threads; if your program doesn't fit this model then increasing this option may help performance.

The main thread is normally started with a slightly larger heap to cut down on unnecessary stack growth while the program is starting up.

-Ksize
[Default: 8M] Set the maximum stack size for an individual thread to size bytes. This option is there purely to stop the program eating up all the available memory in the machine if it gets into an infinite loop.

On Jun 7, 2011, at 3:55 AM, Johannes Waldmann wrote:

> 
>> As a workaround, you can use the "show-ghc-events" binary that is
>> provided by the ghc-events package.
> 
> Thanks, I wasn't aware of that. 
> 
> Are the following lines normal for an eventlog?
> 
> ...
> 1877298000: cap 1: waking up thread 4 on cap 1
> 1877299000: cap 1: thread 4 is runnable
> 1877305000: cap 6: thread 4 is runnable
> 1877306000: cap 1: migrating thread 4 to cap 6
> 1877334000: cap 1: running thread 16
> 1877345000: cap 6: running thread 4
> 1877348000: cap 6: stopping thread 4 (thread finished)
> 1877428000: cap 3: stopping thread 14 (stack overflow)
> 1877428000: cap 3: running thread 14
> 1877501000: cap 1: stopping thread 16 (stack overflow)
> 1877503000: cap 1: running thread 16
> 1877606000: cap 3: stopping thread 14 (stack overflow)
> 1877607000: cap 3: running thread 14
> 1877658000: cap 1: stopping thread 16 (stack overflow)
> 1877659000: cap 1: running thread 16
> 1877723000: cap 4: stopping thread 10 (stack overflow)
> 1877724000: cap 4: running thread 10
> 1877769000: cap 3: stopping thread 14 (stack overflow)
> 1877770000: cap 3: running thread 14
> ...
> 
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
> 




More information about the Haskell-Cafe mailing list