Unexpected pprof
heap output means buggy pprof
or misunderstanding in how pprof
heap output works
#49152
Labels
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Have not tried.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I have not tried to reproduce this in a smaller standalone program. The
pprof
output shown below is the product of a larger Golang program running for several days. I posted it here mainly to sanity check my understanding of howpprof
works, because based on my current understandingpprof
seems to not work as expected, i.e. is it buggy?What did you expect to see?
Expected to see top
inuse_space
itemgit.colasdn.top/hashicorp/golang-lru/simplelru.(*LRU).Add
inpprof
heap output for allpprof
heap modes includingalloc_space
andalloc_objects
, and not justinuse_space
andinuse_objects
.What did you see instead?
I've been using
pprof
to examine heap usage, and am getting confused by the results, making me think that there might be a bug inpprof
? Otherwise, how to explain the results below?So after collecting the file
profiler/heap-2021-10-18T15:52:15Z
output bypprof
then I run thepprof
commandtop9999
on the file using the 4 different modes;inuse_space
,inuse_objects
,alloc_space
, andalloc_objects
:This gives 4 different text files containing the output, and here are their lengths in bytes:
The output files are quite big, but here are the first lines of each of them:
I'm looking at
github.com/hashicorp/golang-lru/simplelru.(*LRU).Add
which is 'top' forinuse_space
(355 MB out of 1,516 MB) and 2nd top forinuse_objects
(9,224,542 out of 23,144,863 objects).I'm assuming
inuse_...
means heap space and objects 'in use' and not yet garbage collected. And I'm assuming thatalloc_...
means heap space and objects 'ever allocated'. For example, if an object is 1MB in size and ever allocated 10 times, but garbage collected 8 times, then for that object I'm expectinginuse_space
to be 2MB,inuse_objects
to be 2,alloc_space
to be 10MB, andalloc_objects
to be 10. Correct?With this in mind then I go looking for
github.com/hashicorp/golang-lru/simplelru.(*LRU).Add
in thealloc_space
andalloc_objects
output, but unexpectedly don't find it:This is lowest line where i would expected to find it in each file (shortened by
...
for brevity). The two bottom lines show the surrounding next highest and lowest counts, e.g. if theinuse_space
forgit.colasdn.top/hashicorp/golang-lru/simplelru.(*LRU).Add
was the result of allocations with no garbage collection, then I would expect to see the 355MB for it sandwiched between the 409MB and 348MB items below... however, it's not there and its not anywhere else to be found in thealloc_space
output. Why not? Is there something wrong with my assumptions about how this works, or could there be a bug inpprof
?The text was updated successfully, but these errors were encountered: