Number of threads in haskell program

Ben Gamari ben at
Wed Mar 4 13:47:47 UTC 2020

"chessai ." <chessai1996 at> writes:

> Hi devs,
> Recently I became interested in obtaining the rough number of (non-GC)
> threads that are alive in a Haskell program. Intuitively this seemed
> like something that the RTS would expose in some way - but I couldn't
> find any such exposition in base. I then thought that I could simply
> total the size of each run_queue_hd in each capability, but the
> machinery for doing that doesn't seem to be exposed. Any thoughts?
Hi Chessai,

Indeed I also needed this functionality in the past. I have a patch
(just posted as !2816) which may need some polish which adds a
`listThreads#` primop. Perhaps you want to pick it up?


- Ben
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: not available
URL: <>

More information about the ghc-devs mailing list