Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions pkg/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,16 @@ func (s *Scheduler) control() {
return
}
numActives := atomic.LoadInt64(&s.numActives)
incomingReqsDiff := s.countIncomingReqs - s.countIncomingReqsL
processedReqsDiff := s.countProcessedReqs - s.countProcessedReqsL
s.countIncomingReqsL = s.countIncomingReqs
s.countProcessedReqsL = s.countProcessedReqs
// Snapshot the two counters with a single atomic load each so
// the diff and the baseline update see the same value. Worker
// goroutines write these via atomic.AddInt64; plain reads here
// are a data race under -race.
incoming := atomic.LoadInt64(&s.countIncomingReqs)
processed := atomic.LoadInt64(&s.countProcessedReqs)
incomingReqsDiff := incoming - s.countIncomingReqsL
processedReqsDiff := processed - s.countProcessedReqsL
s.countIncomingReqsL = incoming
s.countProcessedReqsL = processed

s.runtimeLock.RLock()
shift := s.strategy.ExpandOrShrink(incomingReqsDiff, processedReqsDiff, numActives)
Expand Down
Loading