Skip to content
This repository has been archived by the owner on Mar 29, 2024. It is now read-only.

Commit

Permalink
Initialize and reset slot pace stats correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
dhaavi committed Mar 13, 2023
1 parent 6531ee9 commit bd177b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions unit/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ func NewScheduler(config *SchedulerConfig) *Scheduler {
s.clearanceUpTo.Store(s.config.MinSlotPace)
s.slotPace.Store(s.config.MinSlotPace)

// Initialize stats fields.
s.avgPaceSum.Store(s.config.MinSlotPace)
s.avgPaceCnt.Store(1)

return s
}

Expand Down
4 changes: 2 additions & 2 deletions unit/scheduler_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ func (s *Scheduler) ResetAvgSlotPace() {
// latest slot data, while the other has been not.
// This is not so much of a problem, as slots are really short and the impact
// is very low.
s.avgPaceCnt.Store(0)
s.avgPaceSum.Store(0)
s.avgPaceCnt.Store(1)
s.avgPaceSum.Store(s.config.MinSlotPace)
}

// GetMaxLeveledSlotPace returns the current maximum leveled slot pace.
Expand Down

0 comments on commit bd177b1

Please sign in to comment.