Bläddra i källkod

Apply -1 adjustment to leaf frames for some legacy profiles

Legacy profiles that are not based on interrupt-based sampling
only include addresses that are call stack return addresses. For
them, all callstack addresses should be adjusted by -1 to land
on top of the call instruction and permit accurate symbolization.
Raul Silvera 9 år sedan
förälder
incheckning
d89f0ee907

+ 8
- 17
profile/legacy_profile.go Visa fil

@@ -114,11 +114,8 @@ func parseGoCount(b []byte) (*Profile, error) {
114 114
 			if err != nil {
115 115
 				return nil, errMalformed
116 116
 			}
117
-			// Adjust all frames by -1 (except the leaf) to land on top of
118
-			// the call instruction.
119
-			if len(locs) > 0 {
120
-				addr--
121
-			}
117
+			// Adjust all frames by -1 to land on top of the call instruction.
118
+			addr--
122 119
 			loc := locations[addr]
123 120
 			if loc == nil {
124 121
 				loc = &Location{
@@ -527,13 +524,10 @@ func parseHeap(b []byte) (p *Profile, err error) {
527 524
 		}
528 525
 
529 526
 		var sloc []*Location
530
-		for i, addr := range addrs {
527
+		for _, addr := range addrs {
531 528
 			// Addresses from stack traces point to the next instruction after
532
-			// each call.  Adjust by -1 to land somewhere on the actual call
533
-			// (except for the leaf, which is not a call).
534
-			if i > 0 {
535
-				addr--
536
-			}
529
+			// each call.  Adjust by -1 to land somewhere on the actual call.
530
+			addr--
537 531
 			loc := locs[addr]
538 532
 			if locs[addr] == nil {
539 533
 				loc = &Location{
@@ -769,13 +763,10 @@ func parseContention(b []byte) (p *Profile, err error) {
769 763
 			return nil, err
770 764
 		}
771 765
 		var sloc []*Location
772
-		for i, addr := range addrs {
766
+		for _, addr := range addrs {
773 767
 			// Addresses from stack traces point to the next instruction after
774
-			// each call.  Adjust by -1 to land somewhere on the actual call
775
-			// (except for the leaf, which is not a call).
776
-			if i > 0 {
777
-				addr--
778
-			}
768
+			// each call.  Adjust by -1 to land somewhere on the actual call.
769
+			addr--
779 770
 			loc := locs[addr]
780 771
 			if locs[addr] == nil {
781 772
 				loc = &Location{

+ 1
- 1
profile/testdata/cppbench.contention.string Visa fil

@@ -10,7 +10,7 @@ contentions/count delay/nanoseconds
10 10
         100      75976: 1 15 16 17 18 25 26 27 28 29 30 31 32 33 34 9 
11 11
         300   63568134: 1 35 36 37 38 39 40 6 7 8 9 10 11 12 13 
12 12
 Locations
13
-     1: 0xbccc97 M=1 
13
+     1: 0xbccc96 M=1
14 14
      2: 0xc61201 M=1 
15 15
      3: 0x42ed5e M=1 
16 16
      4: 0x42edc0 M=1 

+ 2
- 2
profile/testdata/cppbench.growth.string Visa fil

@@ -173,7 +173,7 @@ objects/count space/bytes
173 173
           1    2097152: 1 2 3 58 59 60 
174 174
                 bytes:[2097152] 
175 175
 Locations
176
-     1: 0xb83003 M=1 
176
+     1: 0xb83002 M=1
177 177
      2: 0xb87d4f M=1 
178 178
      3: 0xc635ef M=1 
179 179
      4: 0x42ecc2 M=1 
@@ -186,7 +186,7 @@ Locations
186 186
     11: 0x7a296c M=1 
187 187
     12: 0xa456e3 M=1 
188 188
     13: 0x7fcdc2ff214d M=7 
189
-    14: 0xc635c8 M=1 
189
+    14: 0xc635c7 M=1
190 190
     15: 0xafc0ea M=1 
191 191
     16: 0xb087b0 M=1 
192 192
     17: 0xb0aa7c M=1 

+ 2
- 2
profile/testdata/cppbench.heap.string Visa fil

@@ -65,7 +65,7 @@ objects/count space/bytes
65 65
         379   12439381: 1 2 3 4 5 6 7 8 9 10 11 
66 66
                 bytes:[32768] 
67 67
 Locations
68
-     1: 0xc635c8 M=1 
68
+     1: 0xc635c7 M=1
69 69
      2: 0x42ecc2 M=1 
70 70
      3: 0x42e14b M=1 
71 71
      4: 0x5261ae M=1 
@@ -119,7 +119,7 @@ Locations
119 119
     52: 0x41c710 M=1 
120 120
     53: 0xc25cc5 M=1 
121 121
     54: 0x40651a M=1 
122
-    55: 0xc63568 M=1 
122
+    55: 0xc63567 M=1
123 123
     56: 0xbc462d M=1 
124 124
     57: 0xbc4bb4 M=1 
125 125
     58: 0xbc4ed9 M=1 

+ 4
- 4
profile/testdata/go.godoc.thread.string Visa fil

@@ -10,7 +10,7 @@ threadcreate/count
10 10
           1: 1 19 20 21 
11 11
           1: 22 23 
12 12
 Locations
13
-     1: 0x44cb3 M=1 
13
+     1: 0x44cb2 M=1
14 14
      2: 0x45044 M=1 
15 15
      3: 0x45322 M=1 
16 16
      4: 0x45533 M=1 
@@ -23,15 +23,15 @@ Locations
23 23
     11: 0x51583 M=1 
24 24
     12: 0x461df M=1 
25 25
     13: 0x45546 M=1 
26
-    14: 0x40962 M=1 
26
+    14: 0x40962 M=1
27 27
     15: 0x4562d M=1 
28 28
     16: 0x460ec M=1 
29 29
     17: 0x51a58 M=1 
30 30
     18: 0x441ad M=1 
31
-    19: 0x44e03 M=1 
31
+    19: 0x44e03 M=1
32 32
     20: 0x44b7f M=1 
33 33
     21: 0x5192c M=1 
34
-    22: 0x440e2 M=1 
34
+    22: 0x440e1 M=1
35 35
     23: 0x51919 M=1 
36 36
 Mappings
37 37
 1: 0x0/0xffffffffffffffff/0x0   

+ 1
- 1
profile/testdata/gobench.heap.string Visa fil

@@ -33,7 +33,7 @@ alloc_objects/count alloc_space/bytes inuse_objects/count inuse_space/bytes
33 33
       32768     524296          0          0: 1 88 89 90 91 92 93 94 95 96 97 98 99 100 10 
34 34
                 bytes:[16] 
35 35
 Locations
36
-     1: 0x420cef M=1 
36
+     1: 0x420cee M=1
37 37
      2: 0x422150 M=1 
38 38
      3: 0x4221d9 M=1 
39 39
      4: 0x41dc0c M=1