Skip to content

Commit

Permalink
remove redundant timout. return config disposition
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-kasten committed Feb 19, 2024
1 parent 905f6b2 commit 4598a3b
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions internal/pproflogging/pproflogging.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,26 +112,27 @@ func HasProfileBuffersEnabled() bool {
}

// MaybeStartProfileBuffers start profile buffers for this process with a configuration from the environment.
func MaybeStartProfileBuffers(ctx context.Context) {
MaybeStartProfileBuffersWithConfig(ctx, os.Getenv(EnvVarKopiaDebugPprof))
func MaybeStartProfileBuffers(ctx context.Context) bool {
return MaybeStartProfileBuffersWithConfig(ctx, os.Getenv(EnvVarKopiaDebugPprof))
}

// MaybeStartProfileBuffersWithConfig start profile buffers for this process with a custom configuration.
func MaybeStartProfileBuffersWithConfig(ctx context.Context, config string) {
func MaybeStartProfileBuffersWithConfig(ctx context.Context, config string) bool {
pprofConfigs.mu.Lock()
defer pprofConfigs.mu.Unlock()

if !loadAndSetProfileBuffersLocked(ctx, config) {
log(ctx).Debug("no profile buffer configuration to start")
return
return false
}

pprofConfigs.StartProfileBuffersLocked(ctx)
return true
}

// MaybeStopProfileBuffers stop and dump the contents of the buffers to the log as PEMs. Buffers
// supplied here are from MaybeStartProfileBuffers.
func MaybeStopProfileBuffers(ctx context.Context) {
func MaybeStopProfileBuffers(ctx context.Context) bool {
pprofConfigs.mu.Lock()
defer pprofConfigs.mu.Unlock()

Expand Down Expand Up @@ -212,8 +213,8 @@ func (p *ProfileConfigs) StartProfileBuffersLocked(ctx context.Context) {

err := pprof.StartCPUProfile(v.buf)
if err != nil {
delete(p.pcm, ProfileNameCPU)
log(ctx).With("cause", err).Warn("cannot start cpu PPROF")
delete(p.pcm, ProfileNameCPU)
}
}

Expand Down Expand Up @@ -280,9 +281,6 @@ func (p *ProfileConfigs) StopProfileBuffersLocked(ctx context.Context) {
}
}

ctx, canfn := context.WithTimeout(ctx, PPROFDumpTimeout)
defer canfn()

// dump the profiles out into their respective PEMs
for k, v := range p.pcm {
if v == nil {
Expand Down

0 comments on commit 4598a3b

Please sign in to comment.