Browse Source

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)
Hyang-Ah Hana Kim 6 years ago
parent
commit
403a828189
2 changed files with 3 additions and 0 deletions
  1. 1
    0
      profile/legacy_profile.go
  2. 2
    0
      profile/legacy_profile_test.go

+ 1
- 0
profile/legacy_profile.go View File

@@ -1103,6 +1103,7 @@ var heapzSampleTypes = [][]string{
1103 1103
 	{"objects", "space"},
1104 1104
 	{"inuse_objects", "inuse_space"},
1105 1105
 	{"alloc_objects", "alloc_space"},
1106
+	{"alloc_objects", "alloc_space", "inuse_objects", "inuse_space"}, // Go pprof legacy profiles
1106 1107
 }
1107 1108
 var contentionzSampleTypes = [][]string{
1108 1109
 	{"contentions", "delay"},

+ 2
- 0
profile/legacy_profile_test.go View File

@@ -39,10 +39,12 @@ func TestLegacyProfileType(t *testing.T) {
39 39
 		{[]string{"objects", "space"}, heap, true, "heapzSampleTypes"},
40 40
 		{[]string{"inuse_objects", "inuse_space"}, heap, true, "heapzSampleTypes"},
41 41
 		{[]string{"alloc_objects", "alloc_space"}, heap, true, "heapzSampleTypes"},
42
+		{[]string{"alloc_objects", "alloc_space", "inuse_objects", "inuse_space"}, heap, true, "heapzSampleTypes"},
42 43
 		{[]string{"contentions", "delay"}, cont, true, "contentionzSampleTypes"},
43 44
 		// False cases
44 45
 		{[]string{"objects"}, heap, false, "heapzSampleTypes"},
45 46
 		{[]string{"objects", "unknown"}, heap, false, "heapzSampleTypes"},
47
+		{[]string{"inuse_objects", "inuse_space", "alloc_objects", "alloc_space"}, heap, false, "heapzSampleTypes"},
46 48
 		{[]string{"contentions", "delay"}, heap, false, "heapzSampleTypes"},
47 49
 		{[]string{"samples", "cpu"}, heap, false, "heapzSampleTypes"},
48 50
 		{[]string{"samples", "cpu"}, cont, false, "contentionzSampleTypes"},