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

Open
afiskon opened this issue Dec 28, 2018 · 4 comments
Open

doc: runtime/pprof documentation needs clarification #29444

afiskon opened this issue Dec 28, 2018 · 4 comments
Labels
Documentation NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@afiskon
Copy link

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?).

@ianlancetaylor
Copy link
Contributor

Which documentation are you looking at?

@afiskon
Copy link
Author

afiskon commented Dec 29, 2018

@agnivade
Copy link
Contributor

agnivade commented Jan 7, 2019

/cc @hyangah

@hyangah
Copy link
Contributor

hyangah commented Jan 7, 2019

For memory, see the documentation in https://golang.org/pkg/runtime/pprof/#Profile

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.

@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 20, 2022
@seankhliao seankhliao added this to the Unplanned milestone Aug 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

6 participants