[GHC] #10587: Suspending and unsuspending ghci kills and spawns threads

GHC ghc-devs at haskell.org
Wed Jul 1 11:00:12 UTC 2015


#10587: Suspending and unsuspending ghci kills and spawns threads
---------------------------------+-----------------------------------------
        Reporter:  niteria       |                   Owner:  niteria
            Type:  bug           |                  Status:  new
        Priority:  low           |               Milestone:
       Component:  GHCi          |                 Version:  7.10.1
      Resolution:                |                Keywords:
Operating System:  Linux         |            Architecture:  x86_64 (amd64)
 Type of failure:  None/Unknown  |               Test Case:
      Blocked By:                |                Blocking:
 Related Tickets:                |  Differential Revisions:
---------------------------------+-----------------------------------------
Changes (by niteria):

 * cc: AndreasVoellmy (added)


Comment:

 {{{
 ./inplace/bin/ghc-stage2 --interactive -j8 +RTS -Ds
 7f0d94ff9700: returning; I want capability 0
 7f0d94ff9700: resuming capability 0
 7f0d94ff9700: cap 0: running thread 12 (ThreadRunGHC)
 7f0d967fc700: returning; I want capability 0
 7f0dd91ff700: returning; I want capability 0
 7f0dd3fff700: returning; I want capability 0
 7f0d957fa700: returning; I want capability 0
 7f0d96ffd700: returning; I want capability 0
 7f0d73fff700: returning; I want capability 0
 7f0d95ffb700: returning; I want capability 0
 7f0d94ff9700: cap 0: thread 12 stopped (yielding)
 7f0d94ff9700: giving up capability 0
 7f0d94ff9700: passing capability 0 to worker 0x7f0d967fc700
 7f0d967fc700: resuming capability 0
 7f0d967fc700: cap 0: running thread 16 (ThreadRunGHC)
 7f0d967fc700: cap 0: thread 16 stopped (yielding)
 7f0d967fc700: giving up capability 0
 7f0d967fc700: passing capability 0 to worker 0x7f0dd91ff700
 7f0dd91ff700: resuming capability 0
 7f0dd91ff700: cap 0: running thread 2 (ThreadRunGHC)
 7f0dd91ff700: cap 0: thread 2 stopped (yielding)
 7f0dd91ff700: giving up capability 0
 7f0dd91ff700: passing capability 0 to worker 0x7f0dd3fff700
 7f0dd3fff700: resuming capability 0
 7f0dd3fff700: cap 0: running thread 15 (ThreadRunGHC)
 7f0dd3fff700: cap 0: thread 15 stopped (yielding)
 7f0dd3fff700: giving up capability 0
 7f0dd3fff700: passing capability 0 to worker 0x7f0d957fa700
 7f0d957fa700: resuming capability 0
 7f0d957fa700: cap 0: running thread 14 (ThreadRunGHC)
 7f0d957fa700: cap 0: thread 14 stopped (yielding)
 7f0d957fa700: giving up capability 0
 7f0d957fa700: passing capability 0 to worker 0x7f0d96ffd700
 7f0d96ffd700: resuming capability 0
 7f0d96ffd700: cap 0: running thread 18 (ThreadRunGHC)
 7f0d96ffd700: cap 0: thread 18 stopped (yielding)
 7f0d96ffd700: giving up capability 0
 7f0d96ffd700: 6 spare workers already, exiting
 7f0d96ffd700: passing capability 0 to worker 0x7f0d73fff700
 shutdownThread 0x33b047
 7f0d73fff700: resuming capability 0
 7f0d73fff700: cap 0: running thread 13 (ThreadRunGHC)
 7f0d73fff700: cap 0: thread 13 stopped (yielding)
 7f0d73fff700: giving up capability 0
 7f0d73fff700: 6 spare workers already, exiting
 7f0d73fff700: passing capability 0 to worker 0x7f0d95ffb700
 shutdownThread 0x33b04c
 }}}


 After receiving SIGCONT, all the threads (including IO manager threads,
 that were waiting on epoll_wait) wake up and try to get capability 0. They
 eventually succeed and get put on the spare workers queue for this
 capability. The current limit on the the number of spare workers per
 capability is 6, so the remaining 2 threads get shut down.

 Why do we have so many threads?

 When compiling things in parallel we first increase the number of
 capabilities (to 8) and then we restore it (to 1).
 https://phabricator.haskell.org/diffusion/GHC/browse/master/compiler/main/GhcMake.hs;daa5097facb228307d52e5d3e789e5c81494a475$751
 This increases the number of IO manager threads to 8. IO manager doesn't
 decrease the number of threads when the number of capabilities decreases,
 so we keep those threads forever.
 https://phabricator.haskell.org/diffusion/GHC/browse/master/libraries/base/GHC/Event/Thread.hs;daa5097facb228307d52e5d3e789e5c81494a475$325-326

 I believe the fix is to decrease the number of IO manager threads when
 number of capabilities decreases.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10587#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list