Преглед на файлове

Modified dotgraph tag labels so they aren't scaled to graph's unit (#168)

Margaret Nolan преди 8 години
родител
ревизия
92a05378c5
променени са 4 файла, в които са добавени 46 реда и са изтрити 16 реда
  1. 8
    0
      internal/driver/driver_test.go
  2. 30
    0
      internal/driver/testdata/pprof.heap_sizetags.dot
  3. 8
    10
      internal/graph/dotgraph.go
  4. 0
    6
      internal/report/report.go

+ 8
- 0
internal/driver/driver_test.go Целия файл

@@ -70,6 +70,7 @@ func TestParse(t *testing.T) {
70 70
 		{"dot,functions,flat", "cpu"},
71 71
 		{"dot,functions,flat,call_tree", "cpu"},
72 72
 		{"dot,lines,flat,focus=[12]00", "heap"},
73
+		{"dot,unit=minimum", "heap_sizetags"},
73 74
 		{"dot,addresses,flat,ignore=[X3]002,focus=[X1]000", "contention"},
74 75
 		{"dot,files,cum", "contention"},
75 76
 		{"comments", "cpu"},
@@ -391,6 +392,13 @@ func (testFetcher) Fetch(s string, d, t time.Duration) (*profile.Profile, string
391 392
 			{Type: "alloc_objects", Unit: "count"},
392 393
 			{Type: "alloc_space", Unit: "bytes"},
393 394
 		}
395
+	case "heap_sizetags":
396
+		p = heapProfile()
397
+		tags := []int64{2, 4, 8, 16, 32, 64, 128, 256}
398
+		for _, s := range p.Sample {
399
+			s.NumLabel["bytes"] = append(s.NumLabel["bytes"], tags...)
400
+		}
401
+
394 402
 	case "contention":
395 403
 		p = contentionProfile()
396 404
 	case "symbolz":

+ 30
- 0
internal/driver/testdata/pprof.heap_sizetags.dot Целия файл

@@ -0,0 +1,30 @@
1
+digraph "unnamed" {
2
+node [style=filled fillcolor="#f8f8f8"]
3
+subgraph cluster_L { "Build ID: buildid" [shape=box fontsize=16 label="Build ID: buildid\lcomment\lType: inuse_space\lShowing nodes accounting for 93.75MB, 95.05% of 98.63MB total\lDropped 1 node (cum <= 4.93MB)\l"] }
4
+N1 [label="line3002\n31.25MB (31.68%)\nof 94.73MB (96.04%)" fontsize=20 shape=box tooltip="line3002 (94.73MB)" color="#b20200" fillcolor="#edd5d5"]
5
+NN1_0 [label = "16B..64B" fontsize=8 shape=box3d tooltip="93.75MB"]
6
+N1 -> NN1_0 [label=" 93.75MB" weight=100 tooltip="93.75MB" labeltooltip="93.75MB"]
7
+NN1_1 [label = "2B..8B" fontsize=8 shape=box3d tooltip="93.75MB"]
8
+N1 -> NN1_1 [label=" 93.75MB" weight=100 tooltip="93.75MB" labeltooltip="93.75MB"]
9
+NN1_2 [label = "256B..1.56MB" fontsize=8 shape=box3d tooltip="62.50MB"]
10
+N1 -> NN1_2 [label=" 62.50MB" weight=100 tooltip="62.50MB" labeltooltip="62.50MB"]
11
+NN1_3 [label = "128B" fontsize=8 shape=box3d tooltip="31.25MB"]
12
+N1 -> NN1_3 [label=" 31.25MB" weight=100 tooltip="31.25MB" labeltooltip="31.25MB"]
13
+N2 [label="line3000\n0 of 98.63MB (100%)" fontsize=8 shape=box tooltip="line3000 (98.63MB)" color="#b20000" fillcolor="#edd5d5"]
14
+N3 [label="line2001\n62.50MB (63.37%)\nof 63.48MB (64.36%)" fontsize=24 shape=box tooltip="line2001 (63.48MB)" color="#b21600" fillcolor="#edd8d5"]
15
+NN3_0 [label = "16B..64B" fontsize=8 shape=box3d tooltip="190.43MB"]
16
+N3 -> NN3_0 [label=" 190.43MB" weight=100 tooltip="190.43MB" labeltooltip="190.43MB" style="dotted"]
17
+NN3_1 [label = "2B..8B" fontsize=8 shape=box3d tooltip="190.43MB"]
18
+N3 -> NN3_1 [label=" 190.43MB" weight=100 tooltip="190.43MB" labeltooltip="190.43MB" style="dotted"]
19
+NN3_2 [label = "256B..1.56MB" fontsize=8 shape=box3d tooltip="125.98MB"]
20
+N3 -> NN3_2 [label=" 125.98MB" weight=100 tooltip="125.98MB" labeltooltip="125.98MB" style="dotted"]
21
+NN3_3 [label = "128B" fontsize=8 shape=box3d tooltip="63.48MB"]
22
+N3 -> NN3_3 [label=" 63.48MB" weight=100 tooltip="63.48MB" labeltooltip="63.48MB" style="dotted"]
23
+N4 [label="line2000\n0 of 63.48MB (64.36%)" fontsize=8 shape=box tooltip="line2000 (63.48MB)" color="#b21600" fillcolor="#edd8d5"]
24
+N5 [label="line3001\n0 of 36.13MB (36.63%)" fontsize=8 shape=box tooltip="line3001 (36.13MB)" color="#b22e00" fillcolor="#eddbd5"]
25
+N4 -> N3 [label=" 63.48MB\n (inline)" weight=65 penwidth=4 color="#b21600" tooltip="line2000 -> line2001 (63.48MB)" labeltooltip="line2000 -> line2001 (63.48MB)"]
26
+N1 -> N4 [label=" 63.48MB" weight=65 penwidth=4 color="#b21600" tooltip="line3002 -> line2000 (63.48MB)" labeltooltip="line3002 -> line2000 (63.48MB)" minlen=2]
27
+N2 -> N1 [label=" 62.50MB\n (inline)" weight=64 penwidth=4 color="#b21600" tooltip="line3000 -> line3002 (62.50MB)" labeltooltip="line3000 -> line3002 (62.50MB)"]
28
+N2 -> N5 [label=" 36.13MB\n (inline)" weight=37 penwidth=2 color="#b22e00" tooltip="line3000 -> line3001 (36.13MB)" labeltooltip="line3000 -> line3001 (36.13MB)"]
29
+N5 -> N1 [label=" 32.23MB\n (inline)" weight=33 penwidth=2 color="#b23200" tooltip="line3001 -> line3002 (32.23MB)" labeltooltip="line3001 -> line3002 (32.23MB)"]
30
+}

+ 8
- 10
internal/graph/dotgraph.go Целия файл

@@ -46,9 +46,8 @@ type DotConfig struct {
46 46
 	LegendURL string   // The URL to link to from the legend.
47 47
 	Labels    []string // The labels for the DOT's legend
48 48
 
49
-	FormatValue func(int64) string         // A formatting function for values
50
-	FormatTag   func(int64, string) string // A formatting function for numeric tags
51
-	Total       int64                      // The total weight of the graph, used to compute percentages
49
+	FormatValue func(int64) string // A formatting function for values
50
+	Total       int64              // The total weight of the graph, used to compute percentages
52 51
 }
53 52
 
54 53
 const maxNodelets = 4 // Number of nodelets for labels (both numeric and non)
@@ -450,14 +449,9 @@ func tagDistance(t, u *Tag) float64 {
450 449
 }
451 450
 
452 451
 func (b *builder) tagGroupLabel(g []*Tag) (label string, flat, cum int64) {
453
-	formatTag := b.config.FormatTag
454
-	if formatTag == nil {
455
-		formatTag = measurement.Label
456
-	}
457
-
458 452
 	if len(g) == 1 {
459 453
 		t := g[0]
460
-		return formatTag(t.Value, t.Unit), t.FlatValue(), t.CumValue()
454
+		return measurement.Label(t.Value, t.Unit), t.FlatValue(), t.CumValue()
461 455
 	}
462 456
 	min := g[0]
463 457
 	max := g[0]
@@ -481,7 +475,11 @@ func (b *builder) tagGroupLabel(g []*Tag) (label string, flat, cum int64) {
481 475
 	if dc != 0 {
482 476
 		c = c / dc
483 477
 	}
484
-	return formatTag(min.Value, min.Unit) + ".." + formatTag(max.Value, max.Unit), f, c
478
+
479
+	// Tags are not scaled with the selected output unit because tags are often
480
+	// much smaller than other values which appear, so the range of tag sizes
481
+	// sometimes would appear to be "0..0" when scaled to the selected output unit.
482
+	return measurement.Label(min.Value, min.Unit) + ".." + measurement.Label(max.Value, max.Unit), f, c
485 483
 }
486 484
 
487 485
 func min64(a, b int64) int64 {

+ 0
- 6
internal/report/report.go Целия файл

@@ -982,16 +982,10 @@ func GetDOT(rpt *Report) (*graph.Graph, *graph.DotConfig) {
982 982
 	rpt.selectOutputUnit(g)
983 983
 	labels := reportLabels(rpt, g, origCount, droppedNodes, droppedEdges, true)
984 984
 
985
-	o := rpt.options
986
-	formatTag := func(v int64, key string) string {
987
-		return measurement.ScaledLabel(v, key, o.OutputUnit)
988
-	}
989
-
990 985
 	c := &graph.DotConfig{
991 986
 		Title:       rpt.options.Title,
992 987
 		Labels:      labels,
993 988
 		FormatValue: rpt.formatValue,
994
-		FormatTag:   formatTag,
995 989
 		Total:       rpt.total,
996 990
 	}
997 991
 	return g, c