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 7 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
 	{"objects", "space"},
1103
 	{"objects", "space"},
1104
 	{"inuse_objects", "inuse_space"},
1104
 	{"inuse_objects", "inuse_space"},
1105
 	{"alloc_objects", "alloc_space"},
1105
 	{"alloc_objects", "alloc_space"},
1106
+	{"alloc_objects", "alloc_space", "inuse_objects", "inuse_space"}, // Go pprof legacy profiles
1106
 }
1107
 }
1107
 var contentionzSampleTypes = [][]string{
1108
 var contentionzSampleTypes = [][]string{
1108
 	{"contentions", "delay"},
1109
 	{"contentions", "delay"},

+ 2
- 0
profile/legacy_profile_test.go View File

39
 		{[]string{"objects", "space"}, heap, true, "heapzSampleTypes"},
39
 		{[]string{"objects", "space"}, heap, true, "heapzSampleTypes"},
40
 		{[]string{"inuse_objects", "inuse_space"}, heap, true, "heapzSampleTypes"},
40
 		{[]string{"inuse_objects", "inuse_space"}, heap, true, "heapzSampleTypes"},
41
 		{[]string{"alloc_objects", "alloc_space"}, heap, true, "heapzSampleTypes"},
41
 		{[]string{"alloc_objects", "alloc_space"}, heap, true, "heapzSampleTypes"},
42
+		{[]string{"alloc_objects", "alloc_space", "inuse_objects", "inuse_space"}, heap, true, "heapzSampleTypes"},
42
 		{[]string{"contentions", "delay"}, cont, true, "contentionzSampleTypes"},
43
 		{[]string{"contentions", "delay"}, cont, true, "contentionzSampleTypes"},
43
 		// False cases
44
 		// False cases
44
 		{[]string{"objects"}, heap, false, "heapzSampleTypes"},
45
 		{[]string{"objects"}, heap, false, "heapzSampleTypes"},
45
 		{[]string{"objects", "unknown"}, heap, false, "heapzSampleTypes"},
46
 		{[]string{"objects", "unknown"}, heap, false, "heapzSampleTypes"},
47
+		{[]string{"inuse_objects", "inuse_space", "alloc_objects", "alloc_space"}, heap, false, "heapzSampleTypes"},
46
 		{[]string{"contentions", "delay"}, heap, false, "heapzSampleTypes"},
48
 		{[]string{"contentions", "delay"}, heap, false, "heapzSampleTypes"},
47
 		{[]string{"samples", "cpu"}, heap, false, "heapzSampleTypes"},
49
 		{[]string{"samples", "cpu"}, heap, false, "heapzSampleTypes"},
48
 		{[]string{"samples", "cpu"}, cont, false, "contentionzSampleTypes"},
50
 		{[]string{"samples", "cpu"}, cont, false, "contentionzSampleTypes"},