schedulePushWork: avoid unnecessary wakeups

Authored by simonmar on Apr 24 2016, 3:31 PM.

Description

schedulePushWork: avoid unnecessary wakeups

This function had some pathalogically bad behaviour: if we had 2 threads
on the current capability and 23 other idle capabilities, we would

  • grab all 23 capabilities
  • migrate one Haskell thread to one of them
  • wake up a worker on *all* 23 other capabilities.

This lead to a lot of unnecessary wakeups when using large -N values.

Now, we

  • Count how many capabilities we need to wake up
  • Start from cap->no+1, so that we don't overload low-numbered capabilities
  • Only wake up capabilities that we migrated a thread to (unless we have sparks to steal)

This results in a pretty dramatic improvement in our production system.

(cherry picked from commit 1fa92ca9b1ed4cf44e2745830c9e9ccc2bee12d5)

Details

Committed
bgamariAug 25 2016, 10:23 AM
Parents
rGHC29f610da83bc: Allow limiting the number of GC threads (+RTS -qn<n>)
Branches
Unknown
Tags
Unknown