Skip to content

Commit 18a9830

Browse files
committed
Mark inlined frames as such in the traces report.
1 parent f11f1df commit 18a9830

File tree

5 files changed

+70
-23
lines changed

5 files changed

+70
-23
lines changed

internal/driver/driver_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ func TestParse(t *testing.T) {
8686
{"tags", "heap"},
8787
{"tags,unit=bytes", "heap"},
8888
{"traces", "cpu"},
89+
{"traces,addresses", "cpu"},
8990
{"traces", "heap_tags"},
9091
{"dot,alloc_space,flat,focus=[234]00", "heap_alloc"},
9192
{"dot,alloc_space,flat,tagshow=[2]00", "heap_alloc"},
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
-----------+-------------------------------------------------------

internal/driver/testdata/pprof.cpu.traces

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,28 @@ Duration: 10s, Total samples = 1.12s (11.20%)
55
key1: tag1
66
key2: tag1
77
1s line1000
8-
line2001
8+
line2001 (inline)
99
line2000
10-
line3002
11-
line3001
10+
line3002 (inline)
11+
line3001 (inline)
1212
line3000
1313
-----------+-------------------------------------------------------
1414
key1: tag2
1515
key3: tag2
1616
100ms line1000
17-
line3001
17+
line3001 (inline)
1818
line3000
1919
-----------+-------------------------------------------------------
2020
key1: tag3
2121
key2: tag2
22-
10ms line2001
22+
10ms line2001 (inline)
2323
line2000
24-
line3002
24+
line3002 (inline)
2525
line3000
2626
-----------+-------------------------------------------------------
2727
key1: tag4
2828
key2: tag1
29-
10ms line3002
30-
line3001
29+
10ms line3002 (inline)
30+
line3001 (inline)
3131
line3000
3232
-----------+-------------------------------------------------------

internal/driver/testdata/pprof.heap_tags.traces

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@ Type: inuse_space
66
bytes: 100kB
77
request: 100kB
88
1000kB line1000
9-
line2001
9+
line2001 (inline)
1010
line2000
11-
line3002
12-
line3001
11+
line3002 (inline)
12+
line3001 (inline)
1313
line3000
1414
-----------+-------------------------------------------------------
1515
bytes: 200kB
1616
3.91MB line1000
17-
line3001
17+
line3001 (inline)
1818
line3000
1919
-----------+-------------------------------------------------------
2020
key1: tag
2121
bytes: 1.56MB
2222
request: 1.56MB
23-
62.50MB line2001
23+
62.50MB line2001 (inline)
2424
line2000
25-
line3002
25+
line3002 (inline)
2626
line3000
2727
-----------+-------------------------------------------------------
2828
bytes: 400kB
29-
31.25MB line3002
30-
line3001
29+
31.25MB line3002 (inline)
30+
line3001 (inline)
3131
line3000
3232
-----------+-------------------------------------------------------

internal/report/report.go

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -834,10 +834,19 @@ func printTraces(w io.Writer, rpt *Report) error {
834834

835835
_, locations := graph.CreateNodes(prof, &graph.Options{})
836836
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
838842
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+
}
841850
}
842851

843852
if len(stack) == 0 {
@@ -875,10 +884,15 @@ func printTraces(w io.Writer, rpt *Report) error {
875884
if d != 0 {
876885
v = v / d
877886
}
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)
882896
}
883897
}
884898
fmt.Fprintln(w, separator)

0 commit comments

Comments
 (0)