I'm profiling a Go application with pprof.
The application is using about 4-10% CPU and leaving it running for a short while produces a profile of around 6-11kb. This suggests to me that it should be able to sample some activity.
When I view the result, however, I see the following:
$ go tool pprof --text bigproc
1.77s of 1.77s total ( 100%)
flat flat% sum% cum cum%
1.77s 100% 100% 1.77s 100%
$
The interesting information appears to be missing. What could be wrong?
This is on linux, with go version 1.6.1 and pprof version 2.2.1 of google-perftools (if that matters).
You are mis-using the go tool pprof
, because you shall specify the executable file associated with the generated profile.
Compare this
$ go tool pprof --text cpuprofile.prof
680ms of 680ms total ( 100%)
flat flat% sum% cum cum%
680ms 100% 100% 680ms 100%
with this (note main
, that is the executable that produced the cpuprofile.prof
)
$ go tool pprof --text main cpuprofile.prof
680ms of 680ms total ( 100%)
flat flat% sum% cum cum%
350ms 51.47% 51.47% 610ms 89.71% main.renderMandelbrotUnified
130ms 19.12% 70.59% 130ms 19.12% math.Log
40ms 5.88% 76.47% 60ms 8.82% image.(*RGBA).Set
[cut]
It's not a matter of wrong sampling: consider that around 100 samples are taken every second of execution, so even of 1.7s you should get some samples anyway (from here):
When CPU profiling is enabled, the Go program stops about 100 times per second and records a sample consisting of the program counters on the currently executing goroutine's stack
Since go 1.9, the binary should be no longer needed, here's an extract from the release notes:
Profiles produced by the runtime/pprof package now include symbol information, so they can be viewed in go tool pprof without the binary that produced the profile.