I'm trying to understand how the parent and various child OS threads work in a haskell program compiled with GHC -threaded
.
Using
module Main where
import Control.Concurrent
main = do
threadDelay 9999999999
Compiling with -threaded
on ghc 8.6.5, and running with +RTS -N3
for instance, I can see
$ pstree -p 6615
hello(6615)─┬─{ghc_ticker}(6618)
├─{hello:w}(6616)
├─{hello:w}(6617)
├─{hello:w}(6619)
├─{hello:w}(6620)
├─{hello:w}(6621)
├─{hello:w}(6622)
└─{hello:w}(6623)
It looks like I get N*2 + 1
of these "hello:w" threads as I vary +RTS -N
.
What are these "hello:w" threads, and why are there apparently two per HEC + 1?
And what does ghc_ticker
do?
I also noticed on a large real service I'm testing with +RTS -N4
I'm getting e.g. 14 of these "my-service:w" threads, and when under load these process IDs seem to churn (half of them stay alive until I kill the service).
Why 14, and why are half of them spawned and die?
I'd also accept an answer that helped guide me to instrumenting my code to figure out these latter two questions.
safe
ffi calls. – Maddocks