From 0b99ea3b16ae2e00851e087771d30e649c2faa4c Mon Sep 17 00:00:00 2001 From: zikaeroh Date: Fri, 4 Dec 2020 12:20:17 -0800 Subject: cmd/vendor: sync pprof@v0.0.0-20201203190320-1bf35d6f28c2 Pulls in a fix to make versioned import paths more readable in pprof's graph view. Updated via the instructions in README.vendor. Updates #36905 Change-Id: I6a91de0f4ca1be3fc69d8e1a39ccf4f5bd0387ef Reviewed-on: https://go-review.googlesource.com/c/go/+/275513 Run-TryBot: Dmitri Shuralyov Reviewed-by: Hyang-Ah Hana Kim Reviewed-by: Dmitri Shuralyov TryBot-Result: Go Bot --- .../github.com/google/pprof/internal/graph/graph.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/cmd/vendor/github.com/google/pprof/internal/graph/graph.go') diff --git a/src/cmd/vendor/github.com/google/pprof/internal/graph/graph.go b/src/cmd/vendor/github.com/google/pprof/internal/graph/graph.go index d2397a93d8..74b904c402 100644 --- a/src/cmd/vendor/github.com/google/pprof/internal/graph/graph.go +++ b/src/cmd/vendor/github.com/google/pprof/internal/graph/graph.go @@ -28,12 +28,14 @@ import ( ) var ( - // Removes package name and method arugments for Java method names. + // Removes package name and method arguments for Java method names. // See tests for examples. javaRegExp = regexp.MustCompile(`^(?:[a-z]\w*\.)*([A-Z][\w\$]*\.(?:|[a-z][\w\$]*(?:\$\d+)?))(?:(?:\()|$)`) - // Removes package name and method arugments for Go function names. + // Removes package name and method arguments for Go function names. // See tests for examples. goRegExp = regexp.MustCompile(`^(?:[\w\-\.]+\/)+(.+)`) + // Removes potential module versions in a package path. + goVerRegExp = regexp.MustCompile(`^(.*?)/v(?:[2-9]|[1-9][0-9]+)([./].*)$`) // Strips C++ namespace prefix from a C++ function / method name. // NOTE: Make sure to keep the template parameters in the name. Normally, // template parameters are stripped from the C++ names but when @@ -317,6 +319,8 @@ func New(prof *profile.Profile, o *Options) *Graph { // nodes. func newGraph(prof *profile.Profile, o *Options) (*Graph, map[uint64]Nodes) { nodes, locationMap := CreateNodes(prof, o) + seenNode := make(map[*Node]bool) + seenEdge := make(map[nodePair]bool) for _, sample := range prof.Sample { var w, dw int64 w = o.SampleValue(sample.Value) @@ -326,8 +330,12 @@ func newGraph(prof *profile.Profile, o *Options) (*Graph, map[uint64]Nodes) { if dw == 0 && w == 0 { continue } - seenNode := make(map[*Node]bool, len(sample.Location)) - seenEdge := make(map[nodePair]bool, len(sample.Location)) + for k := range seenNode { + delete(seenNode, k) + } + for k := range seenEdge { + delete(seenEdge, k) + } var parent *Node // A residual edge goes over one or more nodes that were not kept. residual := false @@ -440,6 +448,7 @@ func newTree(prof *profile.Profile, o *Options) (g *Graph) { // ShortenFunctionName returns a shortened version of a function's name. func ShortenFunctionName(f string) string { f = cppAnonymousPrefixRegExp.ReplaceAllString(f, "") + f = goVerRegExp.ReplaceAllString(f, `${1}${2}`) for _, re := range []*regexp.Regexp{goRegExp, javaRegExp, cppRegExp} { if matches := re.FindStringSubmatch(f); len(matches) >= 2 { return strings.Join(matches[1:], "") -- cgit v1.3