Skip to content

Commit 403a828

Browse files
hyangahaalexand
authored andcommitted
profile: fix legacy format Go heap profile parsing (#382)
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)
1 parent c283c2c commit 403a828

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

profile/legacy_profile.go

+1
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,7 @@ var heapzSampleTypes = [][]string{
11031103
{"objects", "space"},
11041104
{"inuse_objects", "inuse_space"},
11051105
{"alloc_objects", "alloc_space"},
1106+
{"alloc_objects", "alloc_space", "inuse_objects", "inuse_space"}, // Go pprof legacy profiles
11061107
}
11071108
var contentionzSampleTypes = [][]string{
11081109
{"contentions", "delay"},

profile/legacy_profile_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ func TestLegacyProfileType(t *testing.T) {
3939
{[]string{"objects", "space"}, heap, true, "heapzSampleTypes"},
4040
{[]string{"inuse_objects", "inuse_space"}, heap, true, "heapzSampleTypes"},
4141
{[]string{"alloc_objects", "alloc_space"}, heap, true, "heapzSampleTypes"},
42+
{[]string{"alloc_objects", "alloc_space", "inuse_objects", "inuse_space"}, heap, true, "heapzSampleTypes"},
4243
{[]string{"contentions", "delay"}, cont, true, "contentionzSampleTypes"},
4344
// False cases
4445
{[]string{"objects"}, heap, false, "heapzSampleTypes"},
4546
{[]string{"objects", "unknown"}, heap, false, "heapzSampleTypes"},
47+
{[]string{"inuse_objects", "inuse_space", "alloc_objects", "alloc_space"}, heap, false, "heapzSampleTypes"},
4648
{[]string{"contentions", "delay"}, heap, false, "heapzSampleTypes"},
4749
{[]string{"samples", "cpu"}, heap, false, "heapzSampleTypes"},
4850
{[]string{"samples", "cpu"}, cont, false, "contentionzSampleTypes"},

0 commit comments

Comments
 (0)