diff options
| author | Russ Cox <rsc@golang.org> | 2024-02-14 11:57:05 -0500 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-02-29 18:51:47 +0000 |
| commit | adc575e64c8a49c0a14a8a6b0480c5f9815bdb1a (patch) | |
| tree | ffcfd0f85057c6844631632d9e3c6323581aa838 /src/runtime/runtime2.go | |
| parent | 8570aaaf1a1f6cf18c146d7f66016b491847f7f7 (diff) | |
| download | go-adc575e64c8a49c0a14a8a6b0480c5f9815bdb1a.tar.xz | |
runtime: move per-P timers state into its own struct
Continuing conversion from C to Go, introduce type timers
encapsulating all timer heap state, with methods for operations.
This should at least be easier to think about, instead of having
these fields strewn through the P struct. It should also be easier
to test.
I am skeptical about the pair of atomic int64 deadlines:
I think there are missed wakeups lurking.
Having the code in an abstracted API should make it easier
to reason through and fix if needed.
[This is one CL in a refactoring stack making very small changes
in each step, so that any subtle bugs that we miss can be more
easily pinpointed to a small change.]
Change-Id: If5ea3e0b946ca14076f44c85cbb4feb9eddb4f95
Reviewed-on: https://go-review.googlesource.com/c/go/+/564132
Reviewed-by: Austin Clements <austin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/runtime/runtime2.go')
| -rw-r--r-- | src/runtime/runtime2.go | 29 |
1 files changed, 2 insertions, 27 deletions
diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go index 248f489da5..985c1ffab4 100644 --- a/src/runtime/runtime2.go +++ b/src/runtime/runtime2.go @@ -708,16 +708,6 @@ type p struct { palloc persistentAlloc // per-P to avoid mutex - // The when field of the first entry on the timer heap. - // This is 0 if the timer heap is empty. - timer0When atomic.Int64 - - // The earliest known nextwhen field of a timer with - // timerModifiedEarlier status. Because the timer may have been - // modified again, there need not be any timer with this value. - // This is 0 if there are no timerModifiedEarlier timers. - timerModifiedEarliest atomic.Int64 - // Per-P GC state gcAssistTime int64 // Nanoseconds in assistAlloc gcFractionalMarkTime int64 // Nanoseconds in fractional mark worker (atomic) @@ -751,23 +741,8 @@ type p struct { // writing any stats. Its value is even when not, odd when it is. statsSeq atomic.Uint32 - // Lock for timers. We normally access the timers while running - // on this P, but the scheduler can also do it from a different P. - timersLock mutex - - // Actions to take at some time. This is used to implement the - // standard library's time package. - // Must hold timersLock to access. - timers []*timer - - // Number of timers in P's heap. - numTimers atomic.Uint32 - - // Number of timerDeleted timers in P's heap. - deletedTimers atomic.Uint32 - - // Race context used while executing timer functions. - timerRaceCtx uintptr + // Timer heap. + timers timers // maxStackScanDelta accumulates the amount of stack space held by // live goroutines (i.e. those eligible for stack scanning). |
