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>
This commit is contained in:
Dmitri Shuralyov 2025-12-01 11:29:26 -05:00 committed by Gopher Robot
parent 16c0f7e152
commit 4be545115c
10 changed files with 77 additions and 41 deletions

View file

@ -3,7 +3,7 @@ module cmd
go 1.26
require (
github.com/google/pprof v0.0.0-20250630185457-6e76a2b096b5
github.com/google/pprof v0.0.0-20251114195745-4902fdda35c8
golang.org/x/arch v0.23.0
golang.org/x/build v0.0.0-20251128064159-b9bfd88b30e8
golang.org/x/mod v0.30.1-0.20251115032019-269c237cf350

View file

@ -1,7 +1,7 @@
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/google/pprof v0.0.0-20250630185457-6e76a2b096b5 h1:xhMrHhTJ6zxu3gA4enFM9MLn9AY7613teCdFnlUVbSQ=
github.com/google/pprof v0.0.0-20250630185457-6e76a2b096b5/go.mod h1:5hDyRhoBCxViHszMt12TnOpEI4VVi+U8Gm9iphldiMA=
github.com/google/pprof v0.0.0-20251114195745-4902fdda35c8 h1:3DsUAV+VNEQa2CUVLxCY3f87278uWfIDhJnbdvDjvmE=
github.com/google/pprof v0.0.0-20251114195745-4902fdda35c8/go.mod h1:I6V7YzU0XDpsHqbsyrghnFZLO1gwK6NPTNvmetQIk9U=
github.com/ianlancetaylor/demangle v0.0.0-20250417193237-f615e6bd150b h1:ogbOPx86mIhFy764gGkqnkFC8m5PJA7sPzlk9ppLVQA=
github.com/ianlancetaylor/demangle v0.0.0-20250417193237-f615e6bd150b/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw=
github.com/yuin/goldmark v1.6.0 h1:boZcn2GTjpsynOsC0iJHnBWa4Bi0qzfJjthwauItG68=

View file

@ -164,7 +164,7 @@ func init() {
def := defaultConfig()
configFieldMap = map[string]configField{}
t := reflect.TypeOf(config{})
t := reflect.TypeFor[config]()
for i, n := 0, t.NumField(); i < n; i++ {
field := t.Field(i)
js := strings.Split(field.Tag.Get("json"), ",")

View file

@ -10,7 +10,7 @@
</div>
<div class="submenu">
<a title="{{.Help.top}}" href="./top" id="topbtn">Top</a>
<a title="{{.Help.graph}}" href="./" id="graphbtn">Graph</a>
<a title="{{.Help.graph}}" href="./graph" id="graphbtn">Graph</a>
<a title="{{.Help.flamegraph}}" href="./flamegraph" id="flamegraph">Flame Graph</a>
<a title="{{.Help.peek}}" href="./peek" id="peek">Peek</a>
<a title="{{.Help.list}}" href="./source" id="list">Source</a>

View file

@ -125,14 +125,13 @@ func serveWebInterface(hostport string, p *profile.Profile, o *plugin.Options, d
Host: host,
Port: port,
Handlers: map[string]http.Handler{
"/": http.HandlerFunc(ui.dot),
"/": redirectWithQuery("flamegraph", http.StatusMovedPermanently),
"/graph": http.HandlerFunc(ui.dot),
"/top": http.HandlerFunc(ui.top),
"/disasm": http.HandlerFunc(ui.disasm),
"/source": http.HandlerFunc(ui.source),
"/peek": http.HandlerFunc(ui.peek),
"/flamegraph": http.HandlerFunc(ui.stackView),
"/flamegraph2": redirectWithQuery("flamegraph", http.StatusMovedPermanently), // Keep legacy URL working.
"/flamegraphold": redirectWithQuery("flamegraph", http.StatusMovedPermanently), // Keep legacy URL working.
"/saveconfig": http.HandlerFunc(ui.saveConfig),
"/deleteconfig": http.HandlerFunc(ui.deleteConfig),
"/download": http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
@ -140,6 +139,9 @@ func serveWebInterface(hostport string, p *profile.Profile, o *plugin.Options, d
w.Header().Set("Content-Disposition", "attachment;filename=profile.pb.gz")
p.Write(w)
}),
// Keep legacy URLs working.
"/flamegraph2": redirectWithQuery("flamegraph", http.StatusMovedPermanently),
"/flamegraphold": redirectWithQuery("flamegraph", http.StatusMovedPermanently),
},
}

View file

@ -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

View file

@ -36,6 +36,7 @@ package profile
import (
"errors"
"fmt"
"slices"
)
type buffer struct {
@ -187,6 +188,16 @@ func le32(p []byte) uint32 {
return uint32(p[0]) | uint32(p[1])<<8 | uint32(p[2])<<16 | uint32(p[3])<<24
}
func peekNumVarints(data []byte) (numVarints int) {
for ; len(data) > 0; numVarints++ {
var err error
if _, data, err = decodeVarint(data); err != nil {
break
}
}
return numVarints
}
func decodeVarint(data []byte) (uint64, []byte, error) {
var u uint64
for i := 0; ; i++ {
@ -286,6 +297,9 @@ func decodeInt64(b *buffer, x *int64) error {
func decodeInt64s(b *buffer, x *[]int64) error {
if b.typ == 2 {
// Packed encoding
dataLen := peekNumVarints(b.data)
*x = slices.Grow(*x, dataLen)
data := b.data
for len(data) > 0 {
var u uint64
@ -316,8 +330,11 @@ func decodeUint64(b *buffer, x *uint64) error {
func decodeUint64s(b *buffer, x *[]uint64) error {
if b.typ == 2 {
data := b.data
// Packed encoding
dataLen := peekNumVarints(b.data)
*x = slices.Grow(*x, dataLen)
data := b.data
for len(data) > 0 {
var u uint64
var err error

View file

@ -1,5 +1,5 @@
# github.com/google/pprof v0.0.0-20250630185457-6e76a2b096b5
## explicit; go 1.23.0
# github.com/google/pprof v0.0.0-20251114195745-4902fdda35c8
## explicit; go 1.24.0
github.com/google/pprof/driver
github.com/google/pprof/internal/binutils
github.com/google/pprof/internal/driver