From: Hana (Hyang-Ah) Kim Date: Wed, 9 May 2018 01:49:58 +0000 (+0800) Subject: cmd/vendor/.../pprof: update to 520140b6bf47519c766e8380e5f094576347b016 X-Git-Tag: go1.11beta1~463 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=46047e64479c30602f0fb42c6915638006d7335d;p=gostls13.git cmd/vendor/.../pprof: update to 520140b6bf47519c766e8380e5f094576347b016 Change-Id: If431dfa59496b86f58f2ba2a83ca544a28a2a972 Reviewed-on: https://go-review.googlesource.com/112435 Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot --- diff --git a/src/cmd/vendor/github.com/google/pprof/README.md b/src/cmd/vendor/github.com/google/pprof/README.md index e8c2f0329d..81e5d3939d 100644 --- a/src/cmd/vendor/github.com/google/pprof/README.md +++ b/src/cmd/vendor/github.com/google/pprof/README.md @@ -102,8 +102,8 @@ pprof can read `perf.data` files generated by the ## Further documentation -See [doc/pprof.md](doc/pprof.md) for more detailed end-user documentation. +See [doc/README.md](doc/README.md) for more detailed end-user documentation. -See [doc/developer/pprof.dev.md](doc/developer/pprof.dev.md) for developer documentation. +See [CONTRIBUTING.md](CONTRIBUTING.md) for contribution documentation. -See [doc/developer/profile.proto.md](doc/developer/profile.proto.md) for a description of the profile.proto format. +See [proto/README.md](proto/README.md) for a description of the profile.proto format. diff --git a/src/cmd/vendor/github.com/google/pprof/doc/pprof.md b/src/cmd/vendor/github.com/google/pprof/doc/README.md similarity index 99% rename from src/cmd/vendor/github.com/google/pprof/doc/pprof.md rename to src/cmd/vendor/github.com/google/pprof/doc/README.md index 57613fad96..de7c393e78 100644 --- a/src/cmd/vendor/github.com/google/pprof/doc/pprof.md +++ b/src/cmd/vendor/github.com/google/pprof/doc/README.md @@ -94,6 +94,8 @@ Some common pprof options are: *regex*. * **-ignore= _regex_:** Do not include samples that include a report entry matching *regex*. +* **-show\_from= _regex_:** Do not show entries above the first one that + matches *regex*. * **-show= _regex_:** Only show entries that match *regex*. * **-hide= _regex_:** Do not show entries that match *regex*. diff --git a/src/cmd/vendor/github.com/google/pprof/doc/developer/pprof.dev.md b/src/cmd/vendor/github.com/google/pprof/doc/developer/pprof.dev.md deleted file mode 100644 index b2a197f669..0000000000 --- a/src/cmd/vendor/github.com/google/pprof/doc/developer/pprof.dev.md +++ /dev/null @@ -1,14 +0,0 @@ -This is pprof's developer documentation. It discusses how to maintain and extend -pprof. It has yet to be written. - -# How is pprof code structured? - -Internal vs external packages. - -# External interface - -## Plugins - -## Legacy formats - -# Overview of internal packages diff --git a/src/cmd/vendor/github.com/google/pprof/internal/driver/cli.go b/src/cmd/vendor/github.com/google/pprof/internal/driver/cli.go index e2e8c6c936..c3c22e7c96 100644 --- a/src/cmd/vendor/github.com/google/pprof/internal/driver/cli.go +++ b/src/cmd/vendor/github.com/google/pprof/internal/driver/cli.go @@ -316,5 +316,5 @@ var usageMsgVars = "\n\n" + " PPROF_TOOLS Search path for object-level tools\n" + " PPROF_BINARY_PATH Search path for local binary files\n" + " default: $HOME/pprof/binaries\n" + - " finds binaries by $name and $buildid/$name\n" + + " searches $name, $path, $buildid/$name, $path/$buildid\n" + " * On Windows, %USERPROFILE% is used instead of $HOME" diff --git a/src/cmd/vendor/github.com/google/pprof/internal/driver/commands.go b/src/cmd/vendor/github.com/google/pprof/internal/driver/commands.go index 16b0b0a3b5..91d32d1e71 100644 --- a/src/cmd/vendor/github.com/google/pprof/internal/driver/commands.go +++ b/src/cmd/vendor/github.com/google/pprof/internal/driver/commands.go @@ -135,14 +135,6 @@ var pprofVariables = variables{ "Ignore negative differences", "Do not show any locations with values <0.")}, - // Comparisons. - "positive_percentages": &variable{boolKind, "f", "", helpText( - "Ignore negative samples when computing percentages", - "Do not count negative samples when computing the total value", - "of the profile, used to compute percentages. If set, and the -base", - "option is used, percentages reported will be computed against the", - "main profile, ignoring the base profile.")}, - // Graph handling options. "call_tree": &variable{boolKind, "f", "", helpText( "Create a context-sensitive call tree", @@ -161,6 +153,7 @@ var pprofVariables = variables{ "Using auto will scale each value independently to the most natural unit.")}, "compact_labels": &variable{boolKind, "f", "", "Show minimal headers"}, "source_path": &variable{stringKind, "", "", "Search path for source files"}, + "trim_path": &variable{stringKind, "", "", "Path to trim from source paths before search"}, // Filtering options "nodecount": &variable{intKind, "-1", "", helpText( @@ -193,6 +186,10 @@ var pprofVariables = variables{ "Only show nodes matching regexp", "If set, only show nodes that match this location.", "Matching includes the function name, filename or object name.")}, + "show_from": &variable{stringKind, "", "", helpText( + "Drops functions above the highest matched frame.", + "If set, all frames above the highest match are dropped from every sample.", + "Matching includes the function name, filename or object name.")}, "tagfocus": &variable{stringKind, "", "", helpText( "Restricts to samples with tags in range or matched by regexp", "Use name=value syntax to limit the matching to a specific tag.", diff --git a/src/cmd/vendor/github.com/google/pprof/internal/driver/driver.go b/src/cmd/vendor/github.com/google/pprof/internal/driver/driver.go index 3b7439fc9a..acc0b4ad8a 100644 --- a/src/cmd/vendor/github.com/google/pprof/internal/driver/driver.go +++ b/src/cmd/vendor/github.com/google/pprof/internal/driver/driver.go @@ -150,11 +150,11 @@ func generateReport(p *profile.Profile, cmd []string, vars variables, o *plugin. } func applyCommandOverrides(cmd []string, v variables) variables { - trim, focus, tagfocus, hide := v["trim"].boolValue(), true, true, true + trim, tagfilter, filter := v["trim"].boolValue(), true, true switch cmd[0] { case "proto", "raw": - trim, focus, tagfocus, hide = false, false, false, false + trim, tagfilter, filter = false, false, false v.set("addresses", "t") case "callgrind", "kcachegrind": trim = false @@ -163,7 +163,7 @@ func applyCommandOverrides(cmd []string, v variables) variables { trim = false v.set("addressnoinlines", "t") case "peek": - trim, focus, hide = false, false, false + trim, filter = false, false case "list": v.set("nodecount", "0") v.set("lines", "t") @@ -181,17 +181,16 @@ func applyCommandOverrides(cmd []string, v variables) variables { v.set("nodefraction", "0") v.set("edgefraction", "0") } - if !focus { - v.set("focus", "") - v.set("ignore", "") - } - if !tagfocus { + if !tagfilter { v.set("tagfocus", "") v.set("tagignore", "") } - if !hide { + if !filter { + v.set("focus", "") + v.set("ignore", "") v.set("hide", "") v.set("show", "") + v.set("show_from", "") } return v } @@ -242,7 +241,7 @@ func reportOptions(p *profile.Profile, numLabelUnits map[string]string, vars var } var filters []string - for _, k := range []string{"focus", "ignore", "hide", "show", "tagfocus", "tagignore", "tagshow", "taghide"} { + for _, k := range []string{"focus", "ignore", "hide", "show", "show_from", "tagfocus", "tagignore", "tagshow", "taghide"} { v := vars[k].value if v != "" { filters = append(filters, k+"="+v) @@ -250,10 +249,9 @@ func reportOptions(p *profile.Profile, numLabelUnits map[string]string, vars var } ropt := &report.Options{ - CumSort: vars["cum"].boolValue(), - CallTree: vars["call_tree"].boolValue(), - DropNegative: vars["drop_negative"].boolValue(), - PositivePercentages: vars["positive_percentages"].boolValue(), + CumSort: vars["cum"].boolValue(), + CallTree: vars["call_tree"].boolValue(), + DropNegative: vars["drop_negative"].boolValue(), CompactLabels: vars["compact_labels"].boolValue(), Ratio: 1 / vars["divide_by"].floatValue(), @@ -273,6 +271,7 @@ func reportOptions(p *profile.Profile, numLabelUnits map[string]string, vars var OutputUnit: vars["unit"].value, SourcePath: vars["source_path"].stringValue(), + TrimPath: vars["trim_path"].stringValue(), } if len(p.Mapping) > 0 && p.Mapping[0].File != "" { diff --git a/src/cmd/vendor/github.com/google/pprof/internal/driver/driver_focus.go b/src/cmd/vendor/github.com/google/pprof/internal/driver/driver_focus.go index ba5b502ad9..b23ee81058 100644 --- a/src/cmd/vendor/github.com/google/pprof/internal/driver/driver_focus.go +++ b/src/cmd/vendor/github.com/google/pprof/internal/driver/driver_focus.go @@ -33,6 +33,7 @@ func applyFocus(prof *profile.Profile, numLabelUnits map[string]string, v variab ignore, err := compileRegexOption("ignore", v["ignore"].value, err) hide, err := compileRegexOption("hide", v["hide"].value, err) show, err := compileRegexOption("show", v["show"].value, err) + showfrom, err := compileRegexOption("show_from", v["show_from"].value, err) tagfocus, err := compileTagFilter("tagfocus", v["tagfocus"].value, numLabelUnits, ui, err) tagignore, err := compileTagFilter("tagignore", v["tagignore"].value, numLabelUnits, ui, err) prunefrom, err := compileRegexOption("prune_from", v["prune_from"].value, err) @@ -46,6 +47,9 @@ func applyFocus(prof *profile.Profile, numLabelUnits map[string]string, v variab warnNoMatches(hide == nil || hm, "Hide", ui) warnNoMatches(show == nil || hnm, "Show", ui) + sfm := prof.ShowFrom(showfrom) + warnNoMatches(showfrom == nil || sfm, "ShowFrom", ui) + tfm, tim := prof.FilterSamplesByTag(tagfocus, tagignore) warnNoMatches(tagfocus == nil || tfm, "TagFocus", ui) warnNoMatches(tagignore == nil || tim, "TagIgnore", ui) diff --git a/src/cmd/vendor/github.com/google/pprof/internal/driver/driver_test.go b/src/cmd/vendor/github.com/google/pprof/internal/driver/driver_test.go index 06219eae64..309e9950b6 100644 --- a/src/cmd/vendor/github.com/google/pprof/internal/driver/driver_test.go +++ b/src/cmd/vendor/github.com/google/pprof/internal/driver/driver_test.go @@ -65,6 +65,7 @@ func TestParse(t *testing.T) { {"topproto,lines,cum,hide=mangled[X3]0", "cpu"}, {"tree,lines,cum,focus=[24]00", "heap"}, {"tree,relative_percentages,cum,focus=[24]00", "heap"}, + {"tree,lines,cum,show_from=line2", "cpu"}, {"callgrind", "cpu"}, {"callgrind,call_tree", "cpu"}, {"callgrind", "heap"}, @@ -261,6 +262,9 @@ func solutionFilename(source string, f *testFlags) string { if f.strings["ignore"] != "" || f.strings["tagignore"] != "" { name = append(name, "ignore") } + if f.strings["show_from"] != "" { + name = append(name, "show_from") + } name = addString(name, f, []string{"hide", "show"}) if f.strings["unit"] != "minimum" { name = addString(name, f, []string{"unit"}) diff --git a/src/cmd/vendor/github.com/google/pprof/internal/driver/fetch.go b/src/cmd/vendor/github.com/google/pprof/internal/driver/fetch.go index 1b34e70bea..7c576de614 100644 --- a/src/cmd/vendor/github.com/google/pprof/internal/driver/fetch.go +++ b/src/cmd/vendor/github.com/google/pprof/internal/driver/fetch.go @@ -599,9 +599,9 @@ var httpGet = func(source string, timeout time.Duration) (*http.Response, error) client := &http.Client{ Transport: &http.Transport{ - ResponseHeaderTimeout: timeout + 5*time.Second, Proxy: http.ProxyFromEnvironment, TLSClientConfig: tlsConfig, + ResponseHeaderTimeout: timeout + 5*time.Second, }, } return client.Get(source) diff --git a/src/cmd/vendor/github.com/google/pprof/internal/driver/flamegraph.go b/src/cmd/vendor/github.com/google/pprof/internal/driver/flamegraph.go index 29a41011bb..c9b9a5398f 100644 --- a/src/cmd/vendor/github.com/google/pprof/internal/driver/flamegraph.go +++ b/src/cmd/vendor/github.com/google/pprof/internal/driver/flamegraph.go @@ -27,6 +27,7 @@ import ( type treeNode struct { Name string `json:"n"` + FullName string `json:"f"` Cum int64 `json:"v"` CumFormat string `json:"l"` Percent string `json:"p"` @@ -52,8 +53,10 @@ func (ui *webInterface) flamegraph(w http.ResponseWriter, req *http.Request) { // Make all nodes and the map, collect the roots. for _, n := range g.Nodes { v := n.CumValue() + fullName := n.Info.PrintableName() node := &treeNode{ - Name: n.Info.PrintableName(), + Name: getNodeShortName(fullName), + FullName: fullName, Cum: v, CumFormat: config.FormatValue(v), Percent: strings.TrimSpace(measurement.Percentage(v, config.Total)), @@ -78,6 +81,7 @@ func (ui *webInterface) flamegraph(w http.ResponseWriter, req *http.Request) { rootNode := &treeNode{ Name: "root", + FullName: "root", Cum: rootValue, CumFormat: config.FormatValue(rootValue), Percent: strings.TrimSpace(measurement.Percentage(rootValue, config.Total)), @@ -97,3 +101,19 @@ func (ui *webInterface) flamegraph(w http.ResponseWriter, req *http.Request) { Nodes: nodeArr, }) } + +// getNodeShortName builds a short node name from fullName. +func getNodeShortName(name string) string { + chunks := strings.SplitN(name, "(", 2) + head := chunks[0] + pathSep := strings.LastIndexByte(head, '/') + if pathSep == -1 || pathSep+1 >= len(head) { + return name + } + // Check if name is a stdlib package, i.e. doesn't have "." before "/" + if dot := strings.IndexByte(head, '.'); dot == -1 || dot > pathSep { + return name + } + // Trim package path prefix from node name + return name[pathSep+1:] +} diff --git a/src/cmd/vendor/github.com/google/pprof/internal/driver/flamegraph_test.go b/src/cmd/vendor/github.com/google/pprof/internal/driver/flamegraph_test.go new file mode 100644 index 0000000000..c1a887c830 --- /dev/null +++ b/src/cmd/vendor/github.com/google/pprof/internal/driver/flamegraph_test.go @@ -0,0 +1,46 @@ +package driver + +import "testing" + +func TestGetNodeShortName(t *testing.T) { + type testCase struct { + name string + want string + } + testcases := []testCase{ + { + "root", + "root", + }, + { + "syscall.Syscall", + "syscall.Syscall", + }, + { + "net/http.(*conn).serve", + "net/http.(*conn).serve", + }, + { + "github.com/blah/foo.Foo", + "foo.Foo", + }, + { + "github.com/blah/foo_bar.(*FooBar).Foo", + "foo_bar.(*FooBar).Foo", + }, + { + "encoding/json.(*structEncoder).(encoding/json.encode)-fm", + "encoding/json.(*structEncoder).(encoding/json.encode)-fm", + }, + { + "github.com/blah/blah/vendor/gopkg.in/redis.v3.(*baseClient).(github.com/blah/blah/vendor/gopkg.in/redis.v3.process)-fm", + "redis.v3.(*baseClient).(github.com/blah/blah/vendor/gopkg.in/redis.v3.process)-fm", + }, + } + for _, tc := range testcases { + name := getNodeShortName(tc.name) + if got, want := name, tc.want; got != want { + t.Errorf("for %s, got %q, want %q", tc.name, got, want) + } + } +} diff --git a/src/cmd/vendor/github.com/google/pprof/internal/driver/testdata/pprof.cpu.cum.lines.tree.show_from b/src/cmd/vendor/github.com/google/pprof/internal/driver/testdata/pprof.cpu.cum.lines.tree.show_from new file mode 100644 index 0000000000..112b49b383 --- /dev/null +++ b/src/cmd/vendor/github.com/google/pprof/internal/driver/testdata/pprof.cpu.cum.lines.tree.show_from @@ -0,0 +1,16 @@ +Active filters: + show_from=line2 +Showing nodes accounting for 1.01s, 90.18% of 1.12s total +----------------------------------------------------------+------------- + flat flat% sum% cum cum% calls calls% + context +----------------------------------------------------------+------------- + 0 0% 0% 1.01s 90.18% | line2000 testdata/file2000.src:4 + 1.01s 100% | line2001 testdata/file2000.src:9 (inline) +----------------------------------------------------------+------------- + 1.01s 100% | line2000 testdata/file2000.src:4 (inline) + 0.01s 0.89% 0.89% 1.01s 90.18% | line2001 testdata/file2000.src:9 + 1s 99.01% | line1000 testdata/file1000.src:1 +----------------------------------------------------------+------------- + 1s 100% | line2001 testdata/file2000.src:9 + 1s 89.29% 90.18% 1s 89.29% | line1000 testdata/file1000.src:1 +----------------------------------------------------------+------------- diff --git a/src/cmd/vendor/github.com/google/pprof/internal/driver/webhtml.go b/src/cmd/vendor/github.com/google/pprof/internal/driver/webhtml.go index e9bc872035..c3f9c384f8 100644 --- a/src/cmd/vendor/github.com/google/pprof/internal/driver/webhtml.go +++ b/src/cmd/vendor/github.com/google/pprof/internal/driver/webhtml.go @@ -17,13 +17,11 @@ package driver import "html/template" import "github.com/google/pprof/third_party/d3" -import "github.com/google/pprof/third_party/d3tip" import "github.com/google/pprof/third_party/d3flamegraph" // addTemplates adds a set of template definitions to templates. func addTemplates(templates *template.Template) { template.Must(templates.Parse(`{{define "d3script"}}` + d3.JSSource + `{{end}}`)) - template.Must(templates.Parse(`{{define "d3tipscript"}}` + d3tip.JSSource + `{{end}}`)) template.Must(templates.Parse(`{{define "d3flamegraphscript"}}` + d3flamegraph.JSSource + `{{end}}`)) template.Must(templates.Parse(`{{define "d3flamegraphcss"}}` + d3flamegraph.CSSSource + `{{end}}`)) template.Must(templates.Parse(` @@ -224,7 +222,7 @@ table tr td { cursor: ns-resize; } .hilite { - background-color: #ebf5fb; + background-color: #ebf5fb; font-weight: bold; } @@ -1031,49 +1029,51 @@ function viewer(baseUrl, nodes) { width: 90%; min-width: 90%; margin-left: 5%; - padding-bottom: 41px; + padding: 15px 0 35px; } {{template "header" .}}
+
-
{{template "script" .}} - -