Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: runtime/pprof documentation needs clarification #29444

afiskon opened this issue Dec 28, 2018 · 4 comments

doc: runtime/pprof documentation needs clarification #29444

afiskon opened this issue Dec 28, 2018 · 4 comments


Copy link

@afiskon afiskon commented Dec 28, 2018

The documentation is not clear regarding what exactly pprof shows. Here are a few examples.

go tool pprof -http=":8081" http://localhost:8080/debug/pprof/profile?seconds=30

Let's open the flamegraph. There are at least two possibilities:

  1. The flamegraph shows the clock time spent with given stacktrace
  2. The flamegraph shows on-CPU time spent with given stacktrace, i.e. clock time excluding the time spent waiting for disk/network I/O or execution of other programs.

Since I/O can be quite slow these are very different options. Both reports are useful depending on what bottleneck we are trying to fix (I/O or CPU).

go tool pprof -http=":8081" http://localhost:8080/debug/pprof/heap

I'm assuming the flamegraph shows places where given amount of memory was allocated. However it's not clear whether this is 1) the total amount of allocated memory (i.e. it doesn't matter if it was freed), 2) amount of allocated memory of objects that are currently alive, or 3) amount of memory of objects that are not garbage collected yet. Without proper documentation there is no way to tell which option, if any, is correct.

go tool pprof -http=":8081" http://localhost:8080/debug/pprof/block

The time shown doesn't make much sense. On the flamegraph I see something like 18988816179 usec i.e. 5 hours. However the program was executing only for a few minutes. I guess the time should be divided by the number of CPUs or maybe by the number of goroutines (what if it varies?).

Copy link

@ianlancetaylor ianlancetaylor commented Dec 28, 2018

Which documentation are you looking at?

Copy link

@agnivade agnivade commented Jan 7, 2019

/cc @hyangah

Copy link

@hyangah hyangah commented Jan 7, 2019

For memory, see the documentation in

pprof still offers -inuse_space, -inuse_objects, -alloc_space, and -alloc_objects flags for Go's memory profiles.

CPU profile is SIGPROF-based measurement (see man setitimer, ITIMER_PROF) of active CPU cycles.
I agree these need to be clear from the runtime/pprof package doc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants