diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-11-22 23:31:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-22 23:31:01 +0100 |
commit | 6187e724353f2d68943f912e0d8fc1d3d3c1f549 (patch) | |
tree | 45a298d81a731186371dcb6329eefcbf96f73a20 /vendor/github.com/pkg/profile/profile.go | |
parent | 1284260b668168c560e65b803979eb2caff0293a (diff) | |
parent | 885df0cb1ef942dba6ff37d348a4744a9e018a09 (diff) | |
download | podman-6187e724353f2d68943f912e0d8fc1d3d3c1f549.tar.gz podman-6187e724353f2d68943f912e0d8fc1d3d3c1f549.tar.bz2 podman-6187e724353f2d68943f912e0d8fc1d3d3c1f549.zip |
Merge pull request #4544 from containers/dependabot/go_modules/github.com/pkg/profile-1.4.0
build(deps): bump github.com/pkg/profile from 1.3.0 to 1.4.0
Diffstat (limited to 'vendor/github.com/pkg/profile/profile.go')
-rw-r--r-- | vendor/github.com/pkg/profile/profile.go | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/vendor/github.com/pkg/profile/profile.go b/vendor/github.com/pkg/profile/profile.go index 20e285427..b9fdfcfd8 100644 --- a/vendor/github.com/pkg/profile/profile.go +++ b/vendor/github.com/pkg/profile/profile.go @@ -10,6 +10,7 @@ import ( "path/filepath" "runtime" "runtime/pprof" + "runtime/trace" "sync/atomic" ) @@ -20,6 +21,7 @@ const ( blockMode traceMode threadCreateMode + goroutineMode ) // Profile represents an active profiling session. @@ -98,6 +100,10 @@ func TraceProfile(p *Profile) { p.mode = traceMode } // It disables any previous profiling settings. func ThreadcreationProfile(p *Profile) { p.mode = threadCreateMode } +// GoroutineProfile enables goroutine profiling. +// It disables any previous profiling settings. +func GoroutineProfile(p *Profile) { p.mode = goroutineMode } + // ProfilePath controls the base path where various profiling // files are written. If blank, the base path will be generated // by ioutil.TempDir. @@ -189,14 +195,14 @@ func Start(options ...func(*Profile)) interface { if err != nil { log.Fatalf("profile: could not create mutex profile %q: %v", fn, err) } - enableMutexProfile() + runtime.SetMutexProfileFraction(1) logf("profile: mutex profiling enabled, %s", fn) prof.closer = func() { if mp := pprof.Lookup("mutex"); mp != nil { mp.WriteTo(f, 0) } f.Close() - disableMutexProfile() + runtime.SetMutexProfileFraction(0) logf("profile: mutex profiling disabled, %s", fn) } @@ -236,14 +242,29 @@ func Start(options ...func(*Profile)) interface { if err != nil { log.Fatalf("profile: could not create trace output file %q: %v", fn, err) } - if err := startTrace(f); err != nil { + if err := trace.Start(f); err != nil { log.Fatalf("profile: could not start trace: %v", err) } logf("profile: trace enabled, %s", fn) prof.closer = func() { - stopTrace() + trace.Stop() logf("profile: trace disabled, %s", fn) } + + case goroutineMode: + fn := filepath.Join(path, "goroutine.pprof") + f, err := os.Create(fn) + if err != nil { + log.Fatalf("profile: could not create goroutine profile %q: %v", fn, err) + } + logf("profile: goroutine profiling enabled, %s", fn) + prof.closer = func() { + if mp := pprof.Lookup("goroutine"); mp != nil { + mp.WriteTo(f, 0) + } + f.Close() + logf("profile: goroutine profiling disabled, %s", fn) + } } if !prof.noShutdownHook { |