Skip to content

Commit

Permalink
profiler: clarify how pendingProfiles is incremented
Browse files Browse the repository at this point in the history
  • Loading branch information
nsrip-dd committed Sep 29, 2022
1 parent 0fe598f commit c917d48
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions profiler/profiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,14 @@ func (p *profiler) collect(ticker <-chan time.Time) {
p.seq++

completed = completed[:0]
// We need to increment pendingProfiles for every non-CPU
// profile _before_ entering the next loop so that we know CPU
// profiling will not complete until every other profile is
// finished (because p.pendingProfiles will have been
// incremented to count every non-CPU profile before CPU
// profiling starts)
for _, t := range p.enabledProfileTypes() {
if t != CPUProfile {
// pendingProfiles should be updated before
// starting the CPU profiler
p.pendingProfiles.Add(1)
}
}
Expand Down

0 comments on commit c917d48

Please sign in to comment.