diff options
| author | Michael Anthony Knyszek <mknyszek@google.com> | 2025-07-15 17:11:18 +0000 |
|---|---|---|
| committer | Michael Knyszek <mknyszek@google.com> | 2025-07-16 13:31:59 -0700 |
| commit | 385000b004616d5c42c868a2a072432cb65ca692 (patch) | |
| tree | 044fef9d5a13d8024d870be2cd42cec4035b1508 /src/runtime | |
| parent | f506ad2644ff9c76d7e9fa00710248009d449cac (diff) | |
| download | go-385000b004616d5c42c868a2a072432cb65ca692.tar.xz | |
runtime: fix idle time double-counting bug
This change fixes a bug in the accounting of sched.idleTime. In just the
case where the GC CPU limiter needs up-to-date data, sched.idleTime is
incremented in both the P-idle-time and idle-mark-work paths, but it
should only be incremented in the former case.
Fixes #74627.
Change-Id: If41b03da102d47d25bec48ff750a9da27019b71d
Reviewed-on: https://go-review.googlesource.com/c/go/+/687998
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/mgclimit.go | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/runtime/mgclimit.go b/src/runtime/mgclimit.go index ad86fbd65b..80aeb71cad 100644 --- a/src/runtime/mgclimit.go +++ b/src/runtime/mgclimit.go @@ -209,14 +209,12 @@ func (l *gcCPULimiterState) updateLocked(now int64) { for _, pp := range allp { typ, duration := pp.limiterEvent.consume(now) switch typ { - case limiterEventIdleMarkWork: - fallthrough case limiterEventIdle: - idleTime += duration sched.idleTime.Add(duration) - case limiterEventMarkAssist: - fallthrough - case limiterEventScavengeAssist: + idleTime += duration + case limiterEventIdleMarkWork: + idleTime += duration + case limiterEventMarkAssist, limiterEventScavengeAssist: assistTime += duration case limiterEventNone: break @@ -470,14 +468,12 @@ func (e *limiterEvent) stop(typ limiterEventType, now int64) { } // Account for the event. switch typ { - case limiterEventIdleMarkWork: - gcCPULimiter.addIdleTime(duration) case limiterEventIdle: - gcCPULimiter.addIdleTime(duration) sched.idleTime.Add(duration) - case limiterEventMarkAssist: - fallthrough - case limiterEventScavengeAssist: + gcCPULimiter.addIdleTime(duration) + case limiterEventIdleMarkWork: + gcCPULimiter.addIdleTime(duration) + case limiterEventMarkAssist, limiterEventScavengeAssist: gcCPULimiter.addAssistTime(duration) default: throw("limiterEvent.stop: invalid limiter event type found") |
