mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
runtime: only poll network from one P at a time in findRunnable
For #65064 Change-Id: Ifecd7e332d2cf251750752743befeda4ed396f33 Reviewed-on: https://go-review.googlesource.com/c/go/+/564197 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Artur M. Wolff <artur.m.wolff@gmail.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com> Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
parent
336626bac4
commit
352dd2d932
@ -3387,8 +3387,12 @@ top:
|
|||||||
// blocked thread (e.g. it has already returned from netpoll, but does
|
// blocked thread (e.g. it has already returned from netpoll, but does
|
||||||
// not set lastpoll yet), this thread will do blocking netpoll below
|
// not set lastpoll yet), this thread will do blocking netpoll below
|
||||||
// anyway.
|
// anyway.
|
||||||
if netpollinited() && netpollAnyWaiters() && sched.lastpoll.Load() != 0 {
|
// We only poll from one thread at a time to avoid kernel contention
|
||||||
if list, delta := netpoll(0); !list.empty() { // non-blocking
|
// on machines with many cores.
|
||||||
|
if netpollinited() && netpollAnyWaiters() && sched.lastpoll.Load() != 0 && sched.pollingNet.Swap(1) == 0 {
|
||||||
|
list, delta := netpoll(0)
|
||||||
|
sched.pollingNet.Store(0)
|
||||||
|
if !list.empty() { // non-blocking
|
||||||
gp := list.pop()
|
gp := list.pop()
|
||||||
injectglist(&list)
|
injectglist(&list)
|
||||||
netpollAdjustWaiters(delta)
|
netpollAdjustWaiters(delta)
|
||||||
|
@ -757,9 +757,10 @@ type p struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type schedt struct {
|
type schedt struct {
|
||||||
goidgen atomic.Uint64
|
goidgen atomic.Uint64
|
||||||
lastpoll atomic.Int64 // time of last network poll, 0 if currently polling
|
lastpoll atomic.Int64 // time of last network poll, 0 if currently polling
|
||||||
pollUntil atomic.Int64 // time to which current poll is sleeping
|
pollUntil atomic.Int64 // time to which current poll is sleeping
|
||||||
|
pollingNet atomic.Int32 // 1 if some P doing non-blocking network poll
|
||||||
|
|
||||||
lock mutex
|
lock mutex
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user