diff options
| author | Dmitri Shuralyov <dmitshur@golang.org> | 2025-12-01 11:29:26 -0500 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-12-01 09:15:40 -0800 |
| commit | 4be545115cf8ed42aa0337cbb6c3a92f718192b9 (patch) | |
| tree | dd7495ce97f9d540edc8c71d762d9b8d5c6f0062 /src/cmd/vendor/github.com/google/pprof/internal/graph | |
| parent | 16c0f7e1524c40521312e485b0b0f8b26c95b174 (diff) | |
| download | go-4be545115cf8ed42aa0337cbb6c3a92f718192b9.tar.xz | |
cmd/pprof: update vendored github.com/google/pprof
Pull in the latest published version of github.com/google/pprof
as part of the continuous process of keeping Go's dependencies
up to date.
For #36905.
[git-generate]
cd src/cmd
go get github.com/google/pprof@v0.0.0-20251114195745-4902fdda35c8
go mod tidy
go mod vendor
Change-Id: Id26eb632f637fb2c602d87cb83fdff7f099934ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/725500
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/cmd/vendor/github.com/google/pprof/internal/graph')
| -rw-r--r-- | src/cmd/vendor/github.com/google/pprof/internal/graph/graph.go | 43 |
1 files changed, 30 insertions, 13 deletions
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 c4b0d4869f..ee7a700174 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 @@ -196,6 +196,21 @@ func (i *NodeInfo) NameComponents() []string { return name } +// comparePrintableName compares NodeInfo lexicographically the same way as `i.PrintableName() < right.PrintableName()`, but much more performant. +func (i *NodeInfo) comparePrintableName(right NodeInfo) (equal bool, less bool) { + if right == *i { + return true, false + } + + if i.Address != 0 && right.Address != 0 && i.Address != right.Address { + // comparing ints directly is the same as comparing padded hex from fmt.Sprintf("%016x", Address) + return false, i.Address < right.Address + } + + // fallback + return false, i.PrintableName() < right.PrintableName() +} + // NodeMap maps from a node info struct to a node. It is used to merge // report entries with the same info. type NodeMap map[NodeInfo]*Node @@ -583,17 +598,16 @@ func (nm NodeMap) findOrInsertLine(l *profile.Location, li profile.Line, o *Opti objfile = m.File } - if ni := nodeInfo(l, li, objfile, o); ni != nil { - return nm.FindOrInsertNode(*ni, o.KeptNodes) - } - return nil + ni := nodeInfo(l, li, objfile, o) + + return nm.FindOrInsertNode(ni, o.KeptNodes) } -func nodeInfo(l *profile.Location, line profile.Line, objfile string, o *Options) *NodeInfo { +func nodeInfo(l *profile.Location, line profile.Line, objfile string, o *Options) NodeInfo { if line.Function == nil { - return &NodeInfo{Address: l.Address, Objfile: objfile} + return NodeInfo{Address: l.Address, Objfile: objfile} } - ni := &NodeInfo{ + ni := NodeInfo{ Address: l.Address, Lineno: int(line.Line), Columnno: int(line.Column), @@ -951,8 +965,9 @@ func (ns Nodes) Sort(o NodeOrder) error { if iv, jv := abs64(l.Flat), abs64(r.Flat); iv != jv { return iv > jv } - if iv, jv := l.Info.PrintableName(), r.Info.PrintableName(); iv != jv { - return iv < jv + equal, leftLess := l.Info.comparePrintableName(r.Info) + if !equal { + return leftLess } if iv, jv := abs64(l.Cum), abs64(r.Cum); iv != jv { return iv > jv @@ -969,8 +984,9 @@ func (ns Nodes) Sort(o NodeOrder) error { if iv, jv := abs64(l.Cum), abs64(r.Cum); iv != jv { return iv > jv } - if iv, jv := l.Info.PrintableName(), r.Info.PrintableName(); iv != jv { - return iv < jv + equal, leftLess := l.Info.comparePrintableName(r.Info) + if !equal { + return leftLess } return compareNodes(l, r) }, @@ -1012,8 +1028,9 @@ func (ns Nodes) Sort(o NodeOrder) error { if iv, jv := abs64(score[l]), abs64(score[r]); iv != jv { return iv > jv } - if iv, jv := l.Info.PrintableName(), r.Info.PrintableName(); iv != jv { - return iv < jv + equal, leftLess := l.Info.comparePrintableName(r.Info) + if !equal { + return leftLess } if iv, jv := abs64(l.Flat), abs64(r.Flat); iv != jv { return iv > jv |
