Skip to content

Commit

Permalink
profile: fix legacy format Go heap profile parsing (google#382)
Browse files Browse the repository at this point in the history
This CL fixes a long-lasting bug that prevented pprof from recognizing
Legacy heap profile produced by Go. Go reports four types of samples
at once so the profile includes alloc_objects, alloc_space,
inuse_objects, and inuse_space. The bug caused pprof to misclassify Go
heap profile data and prevent selection of correct filtering/pruning
patterns in analysis.

Update golang/go#25096

Tested with the profile samples included in golang.org/issues/25096
(pprof hides the runtime functions with this change)
  • Loading branch information
hyangah authored and Gabriel Marin committed Dec 17, 2020
1 parent 448c208 commit e1ff4f7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions profile/legacy_profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,7 @@ var heapzSampleTypes = [][]string{
{"objects", "space"},
{"inuse_objects", "inuse_space"},
{"alloc_objects", "alloc_space"},
{"alloc_objects", "alloc_space", "inuse_objects", "inuse_space"}, // Go pprof legacy profiles
}
var contentionzSampleTypes = [][]string{
{"contentions", "delay"},
Expand Down
2 changes: 2 additions & 0 deletions profile/legacy_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ func TestLegacyProfileType(t *testing.T) {
{[]string{"objects", "space"}, heap, true, "heapzSampleTypes"},
{[]string{"inuse_objects", "inuse_space"}, heap, true, "heapzSampleTypes"},
{[]string{"alloc_objects", "alloc_space"}, heap, true, "heapzSampleTypes"},
{[]string{"alloc_objects", "alloc_space", "inuse_objects", "inuse_space"}, heap, true, "heapzSampleTypes"},
{[]string{"contentions", "delay"}, cont, true, "contentionzSampleTypes"},
// False cases
{[]string{"objects"}, heap, false, "heapzSampleTypes"},
{[]string{"objects", "unknown"}, heap, false, "heapzSampleTypes"},
{[]string{"inuse_objects", "inuse_space", "alloc_objects", "alloc_space"}, heap, false, "heapzSampleTypes"},
{[]string{"contentions", "delay"}, heap, false, "heapzSampleTypes"},
{[]string{"samples", "cpu"}, heap, false, "heapzSampleTypes"},
{[]string{"samples", "cpu"}, cont, false, "contentionzSampleTypes"},
Expand Down

0 comments on commit e1ff4f7

Please sign in to comment.