Browse Source

Mark inlined frames as such in the traces report. (#510)

Alexey Alexandrov 5 years ago
parent
commit
d9cc46808a
No account linked to committer's email address

+ 1
- 0
internal/driver/driver_test.go View File

86
 		{"tags", "heap"},
86
 		{"tags", "heap"},
87
 		{"tags,unit=bytes", "heap"},
87
 		{"tags,unit=bytes", "heap"},
88
 		{"traces", "cpu"},
88
 		{"traces", "cpu"},
89
+		{"traces,addresses", "cpu"},
89
 		{"traces", "heap_tags"},
90
 		{"traces", "heap_tags"},
90
 		{"dot,alloc_space,flat,focus=[234]00", "heap_alloc"},
91
 		{"dot,alloc_space,flat,focus=[234]00", "heap_alloc"},
91
 		{"dot,alloc_space,flat,tagshow=[2]00", "heap_alloc"},
92
 		{"dot,alloc_space,flat,tagshow=[2]00", "heap_alloc"},

+ 32
- 0
internal/driver/testdata/pprof.cpu.addresses.traces View File

1
+File: testbinary
2
+Type: cpu
3
+Duration: 10s, Total samples = 1.12s (11.20%)
4
+-----------+-------------------------------------------------------
5
+      key1:  tag1
6
+      key2:  tag1
7
+        1s   0000000000001000 line1000 testdata/file1000.src:1
8
+             0000000000002000 line2001 testdata/file2000.src:9 (inline)
9
+             0000000000002000 line2000 testdata/file2000.src:4
10
+             0000000000003000 line3002 testdata/file3000.src:2 (inline)
11
+             0000000000003000 line3001 testdata/file3000.src:5 (inline)
12
+             0000000000003000 line3000 testdata/file3000.src:6
13
+-----------+-------------------------------------------------------
14
+      key1:  tag2
15
+      key3:  tag2
16
+     100ms   0000000000001000 line1000 testdata/file1000.src:1
17
+             0000000000003001 line3001 testdata/file3000.src:8 (inline)
18
+             0000000000003001 line3000 testdata/file3000.src:9
19
+-----------+-------------------------------------------------------
20
+      key1:  tag3
21
+      key2:  tag2
22
+      10ms   0000000000002000 line2001 testdata/file2000.src:9 (inline)
23
+             0000000000002000 line2000 testdata/file2000.src:4
24
+             0000000000003002 line3002 testdata/file3000.src:5 (inline)
25
+             0000000000003002 line3000 testdata/file3000.src:9
26
+-----------+-------------------------------------------------------
27
+      key1:  tag4
28
+      key2:  tag1
29
+      10ms   0000000000003000 line3002 testdata/file3000.src:2 (inline)
30
+             0000000000003000 line3001 testdata/file3000.src:5 (inline)
31
+             0000000000003000 line3000 testdata/file3000.src:6
32
+-----------+-------------------------------------------------------

+ 8
- 8
internal/driver/testdata/pprof.cpu.traces View File

5
       key1:  tag1
5
       key1:  tag1
6
       key2:  tag1
6
       key2:  tag1
7
         1s   line1000
7
         1s   line1000
8
-             line2001
8
+             line2001 (inline)
9
              line2000
9
              line2000
10
-             line3002
11
-             line3001
10
+             line3002 (inline)
11
+             line3001 (inline)
12
              line3000
12
              line3000
13
 -----------+-------------------------------------------------------
13
 -----------+-------------------------------------------------------
14
       key1:  tag2
14
       key1:  tag2
15
       key3:  tag2
15
       key3:  tag2
16
      100ms   line1000
16
      100ms   line1000
17
-             line3001
17
+             line3001 (inline)
18
              line3000
18
              line3000
19
 -----------+-------------------------------------------------------
19
 -----------+-------------------------------------------------------
20
       key1:  tag3
20
       key1:  tag3
21
       key2:  tag2
21
       key2:  tag2
22
-      10ms   line2001
22
+      10ms   line2001 (inline)
23
              line2000
23
              line2000
24
-             line3002
24
+             line3002 (inline)
25
              line3000
25
              line3000
26
 -----------+-------------------------------------------------------
26
 -----------+-------------------------------------------------------
27
       key1:  tag4
27
       key1:  tag4
28
       key2:  tag1
28
       key2:  tag1
29
-      10ms   line3002
30
-             line3001
29
+      10ms   line3002 (inline)
30
+             line3001 (inline)
31
              line3000
31
              line3000
32
 -----------+-------------------------------------------------------
32
 -----------+-------------------------------------------------------

+ 8
- 8
internal/driver/testdata/pprof.heap_tags.traces View File

6
      bytes:  100kB
6
      bytes:  100kB
7
    request:  100kB
7
    request:  100kB
8
     1000kB   line1000
8
     1000kB   line1000
9
-             line2001
9
+             line2001 (inline)
10
              line2000
10
              line2000
11
-             line3002
12
-             line3001
11
+             line3002 (inline)
12
+             line3001 (inline)
13
              line3000
13
              line3000
14
 -----------+-------------------------------------------------------
14
 -----------+-------------------------------------------------------
15
      bytes:  200kB
15
      bytes:  200kB
16
     3.91MB   line1000
16
     3.91MB   line1000
17
-             line3001
17
+             line3001 (inline)
18
              line3000
18
              line3000
19
 -----------+-------------------------------------------------------
19
 -----------+-------------------------------------------------------
20
       key1:  tag
20
       key1:  tag
21
      bytes:  1.56MB
21
      bytes:  1.56MB
22
    request:  1.56MB
22
    request:  1.56MB
23
-   62.50MB   line2001
23
+   62.50MB   line2001 (inline)
24
              line2000
24
              line2000
25
-             line3002
25
+             line3002 (inline)
26
              line3000
26
              line3000
27
 -----------+-------------------------------------------------------
27
 -----------+-------------------------------------------------------
28
      bytes:  400kB
28
      bytes:  400kB
29
-   31.25MB   line3002
30
-             line3001
29
+   31.25MB   line3002 (inline)
30
+             line3001 (inline)
31
              line3000
31
              line3000
32
 -----------+-------------------------------------------------------
32
 -----------+-------------------------------------------------------

+ 21
- 7
internal/report/report.go View File

834
 
834
 
835
 	_, locations := graph.CreateNodes(prof, &graph.Options{})
835
 	_, locations := graph.CreateNodes(prof, &graph.Options{})
836
 	for _, sample := range prof.Sample {
836
 	for _, sample := range prof.Sample {
837
-		var stack graph.Nodes
837
+		type stk struct {
838
+			*graph.NodeInfo
839
+			inline bool
840
+		}
841
+		var stack []stk
838
 		for _, loc := range sample.Location {
842
 		for _, loc := range sample.Location {
839
-			id := loc.ID
840
-			stack = append(stack, locations[id]...)
843
+			nodes := locations[loc.ID]
844
+			for i, n := range nodes {
845
+				// The inline flag may be inaccurate if 'show' or 'hide' filter is
846
+				// used. See https://github.com/google/pprof/issues/511.
847
+				inline := i != len(nodes)-1
848
+				stack = append(stack, stk{&n.Info, inline})
849
+			}
841
 		}
850
 		}
842
 
851
 
843
 		if len(stack) == 0 {
852
 		if len(stack) == 0 {
875
 		if d != 0 {
884
 		if d != 0 {
876
 			v = v / d
885
 			v = v / d
877
 		}
886
 		}
878
-		fmt.Fprintf(w, "%10s   %s\n",
879
-			rpt.formatValue(v), stack[0].Info.PrintableName())
880
-		for _, s := range stack[1:] {
881
-			fmt.Fprintf(w, "%10s   %s\n", "", s.Info.PrintableName())
887
+		for i, s := range stack {
888
+			var vs, inline string
889
+			if i == 0 {
890
+				vs = rpt.formatValue(v)
891
+			}
892
+			if s.inline {
893
+				inline = " (inline)"
894
+			}
895
+			fmt.Fprintf(w, "%10s   %s%s\n", vs, s.PrintableName(), inline)
882
 		}
896
 		}
883
 	}
897
 	}
884
 	fmt.Fprintln(w, separator)
898
 	fmt.Fprintln(w, separator)