1. 23 Nov, 2016 6 commits
  2. 22 Nov, 2016 21 commits
  3. 21 Nov, 2016 8 commits
  4. 20 Nov, 2016 2 commits
    • Austin Clements's avatar
      runtime: wake idle Ps when enqueuing GC work · 0bae74e8
      Austin Clements authored
      If the scheduler has no user work and there's no GC work visible, it
      puts the P to sleep (or blocks on the network). However, if we later
      enqueue more GC work, there's currently nothing that specifically
      wakes up the scheduler to let it start an idle GC worker. As a result,
      we can underutilize the CPU during GC if Ps have been put to sleep.
      
      Fix this by making GC wake idle Ps when work buffers are put on the
      full list. We already have a hook to do this, since we use this to
      preempt a random P if we need more dedicated workers. We expand this
      hook to instead wake an idle P if there is one. The logic we use for
      this is identical to the logic used to wake an idle P when we ready a
      goroutine.
      
      To make this really sound, we also fix the scheduler to re-check the
      idle GC worker condition after releasing its P. This closes a race
      where 1) the scheduler checks for idle work and finds none, 2) new
      work is enqueued but there are no idle Ps so none are woken, and 3)
      the scheduler releases its P.
      
      There is one subtlety here. Currently we call enlistWorker directly
      from putfull, but the gcWork is in an inconsistent state in the places
      that call putfull. This isn't a problem right now because nothing that
      enlistWorker does touches the gcWork, but with the added call to
      wakep, it's possible to get a recursive call into the gcWork
      (specifically, while write barriers are disallowed, this can do an
      allocation, which can dispose a gcWork, which can put a workbuf). To
      handle this, we lift the enlistWorker calls up a layer and delay them
      until the gcWork is in a consistent state.
      
      Fixes #14179.
      
      Change-Id: Ia2467a52e54c9688c3c1752e1fc00f5b37bbfeeb
      Reviewed-on: https://go-review.googlesource.com/32434
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarDmitry Vyukov <dvyukov@google.com>
      0bae74e8
    • Austin Clements's avatar
      runtime: exit idle worker if there's higher-priority work · 49ea9207
      Austin Clements authored
      Idle GC workers trigger whenever there's a GC running and the
      scheduler doesn't find any other work. However, they currently run for
      a full scheduler quantum (~10ms) once started.
      
      This is really bad for event-driven applications, where work may come
      in on the network hundreds of times during that window. In the
      go-gcbench rpc benchmark, this is bad enough to often cause effective
      STWs where all Ps are in the idle worker. When this happens, we don't
      even poll the network any more (except for the background 10ms poll in
      sysmon), so we don't even know there's more work to do.
      
      Fix this by making idle workers check with the scheduler roughly every
      100 µs to see if there's any higher-priority work the P should be
      doing. This check includes polling the network for incoming work.
      
      Fixes #16528.
      
      Change-Id: I6f62ebf6d36a92368da9891bafbbfd609b9bd003
      Reviewed-on: https://go-review.googlesource.com/32433
      Run-TryBot: Austin Clements <austin@google.com>
      TryBot-Result: Gobot Gobot <gobot@golang.org>
      Reviewed-by: default avatarRick Hudson <rlh@golang.org>
      49ea9207
  5. 19 Nov, 2016 1 commit
  6. 18 Nov, 2016 2 commits