mirror of
https://github.com/golang/go
synced 2024-11-18 07:34:53 -07:00
runtime: account mark worker time before gcMarkDone
Currently gcMarkDone takes basically no time, so it's okay to account the worker time after calling it. However, gcMarkDone is about to take potentially *much* longer because it may perform all of mark termination. Prepare for this by swapping the order so we account the time before calling gcMarkDone. Change-Id: I90c7df68192acfc4fd02a7254dae739dda4e2fcb Reviewed-on: https://go-review.googlesource.com/16390 Reviewed-by: Rick Hudson <rlh@golang.org> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
171204b561
commit
d986bf2741
@ -1477,6 +1477,19 @@ func gcBgMarkWorker(p *p) {
|
||||
p.gcw.dispose()
|
||||
}
|
||||
|
||||
// Account for time.
|
||||
duration := nanotime() - startTime
|
||||
switch p.gcMarkWorkerMode {
|
||||
case gcMarkWorkerDedicatedMode:
|
||||
xaddint64(&gcController.dedicatedMarkTime, duration)
|
||||
xaddint64(&gcController.dedicatedMarkWorkersNeeded, 1)
|
||||
case gcMarkWorkerFractionalMode:
|
||||
xaddint64(&gcController.fractionalMarkTime, duration)
|
||||
xaddint64(&gcController.fractionalMarkWorkersNeeded, 1)
|
||||
case gcMarkWorkerIdleMode:
|
||||
xaddint64(&gcController.idleMarkTime, duration)
|
||||
}
|
||||
|
||||
// Was this the last worker and did we run out
|
||||
// of work?
|
||||
incnwait := xadd(&work.nwait, +1)
|
||||
@ -1491,18 +1504,6 @@ func gcBgMarkWorker(p *p) {
|
||||
if incnwait == work.nproc && !gcMarkWorkAvailable(nil) {
|
||||
gcMarkDone()
|
||||
}
|
||||
|
||||
duration := nanotime() - startTime
|
||||
switch p.gcMarkWorkerMode {
|
||||
case gcMarkWorkerDedicatedMode:
|
||||
xaddint64(&gcController.dedicatedMarkTime, duration)
|
||||
xaddint64(&gcController.dedicatedMarkWorkersNeeded, 1)
|
||||
case gcMarkWorkerFractionalMode:
|
||||
xaddint64(&gcController.fractionalMarkTime, duration)
|
||||
xaddint64(&gcController.fractionalMarkWorkersNeeded, 1)
|
||||
case gcMarkWorkerIdleMode:
|
||||
xaddint64(&gcController.idleMarkTime, duration)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user