浏览代码

Allow trees to trim to the top Nodes by NodeInfo

In a graph, NodeInfo maps one to one to the nodes, so it suffices to
just find the top NodeInfo s and only keep those nodes in the graph. In
a tree however, a single NodeInfo may map to many nodes. As of this
commit, a call to 'web 10' in pprof on a tree will return all the nodes
corresponding with the top 10 NodeInfo s.
Wade Simba Khadder 8 年前
父节点
当前提交
bee282c062
共有 2 个文件被更改,包括 3 次插入4 次删除
  1. 1
    2
      internal/graph/graph.go
  2. 2
    2
      internal/report/report.go

+ 1
- 2
internal/graph/graph.go 查看文件

288
 	kept := o.KeptNodes
288
 	kept := o.KeptNodes
289
 	keepBinary := o.ObjNames
289
 	keepBinary := o.ObjNames
290
 	parentNodeMap := make(map[*Node]NodeMap, len(prof.Sample))
290
 	parentNodeMap := make(map[*Node]NodeMap, len(prof.Sample))
291
-nextSample:
292
 	for _, sample := range prof.Sample {
291
 	for _, sample := range prof.Sample {
293
 		weight := o.SampleValue(sample.Value)
292
 		weight := o.SampleValue(sample.Value)
294
 		if weight == 0 {
293
 		if weight == 0 {
311
 				}
310
 				}
312
 				n := nodeMap.findOrInsertLine(l, lines[lidx], keepBinary, kept)
311
 				n := nodeMap.findOrInsertLine(l, lines[lidx], keepBinary, kept)
313
 				if n == nil {
312
 				if n == nil {
314
-					continue nextSample
313
+					continue
315
 				}
314
 				}
316
 				n.addSample(weight, labels, sample.NumLabel, o.FormatTag, false)
315
 				n.addSample(weight, labels, sample.NumLabel, o.FormatTag, false)
317
 				if parent != nil {
316
 				if parent != nil {

+ 2
- 2
internal/report/report.go 查看文件

84
 	nodeCutoff := abs64(int64(float64(totalValue) * o.NodeFraction))
84
 	nodeCutoff := abs64(int64(float64(totalValue) * o.NodeFraction))
85
 	edgeCutoff := abs64(int64(float64(totalValue) * o.EdgeFraction))
85
 	edgeCutoff := abs64(int64(float64(totalValue) * o.EdgeFraction))
86
 
86
 
87
-	// Visual mode optimization only supports graph output, not tree.
88
 	// Do not apply edge cutoff to preserve tree structure.
87
 	// Do not apply edge cutoff to preserve tree structure.
89
 	if o.CallTree {
88
 	if o.CallTree {
90
-		visualMode = false
91
 		if o.OutputFormat == Dot {
89
 		if o.OutputFormat == Dot {
90
+			fmt.Println("WARNING: Trimming trees is unsupported.")
91
+			fmt.Printf("Tree will contain at least %d nodes\n", o.NodeCount)
92
 			cumSort = true
92
 			cumSort = true
93
 		}
93
 		}
94
 		edgeCutoff = 0
94
 		edgeCutoff = 0