diff options
Diffstat (limited to 'src/runtime/proc.go')
| -rw-r--r-- | src/runtime/proc.go | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go index cbd3022802..d2903910be 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -3990,7 +3990,11 @@ func checkTimers(pp *p, now int64) (rnow, pollUntil int64, ran bool) { lock(&pp.timersLock) if len(pp.timers) > 0 { - adjusttimers(pp, now) + // If this is the local P, and there are a lot of deleted timers, + // clear them out. We only do this for the local P to reduce + // lock contention on timersLock. + force := pp == getg().m.p.ptr() && int(pp.deletedTimers.Load()) > len(pp.timers)/4 + adjusttimers(pp, now, force) for len(pp.timers) > 0 { // Note that runtimer may temporarily unlock // pp.timersLock. @@ -4004,13 +4008,6 @@ func checkTimers(pp *p, now int64) (rnow, pollUntil int64, ran bool) { } } - // If this is the local P, and there are a lot of deleted timers, - // clear them out. We only do this for the local P to reduce - // lock contention on timersLock. - if pp == getg().m.p.ptr() && int(pp.deletedTimers.Load()) > len(pp.timers)/4 { - clearDeletedTimers(pp) - } - unlock(&pp.timersLock) return now, pollUntil, ran |
