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 go 1.26
require ( 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/arch v0.23.0
golang.org/x/build v0.0.0-20251128064159-b9bfd88b30e8 golang.org/x/build v0.0.0-20251128064159-b9bfd88b30e8
golang.org/x/mod v0.30.1-0.20251115032019-269c237cf350 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 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= 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-20251114195745-4902fdda35c8 h1:3DsUAV+VNEQa2CUVLxCY3f87278uWfIDhJnbdvDjvmE=
github.com/google/pprof v0.0.0-20250630185457-6e76a2b096b5/go.mod h1:5hDyRhoBCxViHszMt12TnOpEI4VVi+U8Gm9iphldiMA= 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 h1:ogbOPx86mIhFy764gGkqnkFC8m5PJA7sPzlk9ppLVQA=
github.com/ianlancetaylor/demangle v0.0.0-20250417193237-f615e6bd150b/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw= github.com/ianlancetaylor/demangle v0.0.0-20250417193237-f615e6bd150b/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw=
github.com/yuin/goldmark v1.6.0 h1:boZcn2GTjpsynOsC0iJHnBWa4Bi0qzfJjthwauItG68= github.com/yuin/goldmark v1.6.0 h1:boZcn2GTjpsynOsC0iJHnBWa4Bi0qzfJjthwauItG68=

View file

@ -151,11 +151,11 @@ func (d *llvmSymbolizer) readCodeFrames() ([]plugin.Frame, error) {
Address string `json:"Address"` Address string `json:"Address"`
ModuleName string `json:"ModuleName"` ModuleName string `json:"ModuleName"`
Symbol []struct { Symbol []struct {
Line int `json:"Line"` Line int `json:"Line"`
Column int `json:"Column"` Column int `json:"Column"`
FunctionName string `json:"FunctionName"` FunctionName string `json:"FunctionName"`
FileName string `json:"FileName"` FileName string `json:"FileName"`
StartLine int `json:"StartLine"` StartLine int `json:"StartLine"`
} `json:"Symbol"` } `json:"Symbol"`
} }
if err := json.Unmarshal([]byte(line), &frame); err != nil { if err := json.Unmarshal([]byte(line), &frame); err != nil {

View file

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

View file

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

View file

@ -125,21 +125,23 @@ func serveWebInterface(hostport string, p *profile.Profile, o *plugin.Options, d
Host: host, Host: host,
Port: port, Port: port,
Handlers: map[string]http.Handler{ Handlers: map[string]http.Handler{
"/": http.HandlerFunc(ui.dot), "/": redirectWithQuery("flamegraph", http.StatusMovedPermanently),
"/top": http.HandlerFunc(ui.top), "/graph": http.HandlerFunc(ui.dot),
"/disasm": http.HandlerFunc(ui.disasm), "/top": http.HandlerFunc(ui.top),
"/source": http.HandlerFunc(ui.source), "/disasm": http.HandlerFunc(ui.disasm),
"/peek": http.HandlerFunc(ui.peek), "/source": http.HandlerFunc(ui.source),
"/flamegraph": http.HandlerFunc(ui.stackView), "/peek": http.HandlerFunc(ui.peek),
"/flamegraph2": redirectWithQuery("flamegraph", http.StatusMovedPermanently), // Keep legacy URL working. "/flamegraph": http.HandlerFunc(ui.stackView),
"/flamegraphold": redirectWithQuery("flamegraph", http.StatusMovedPermanently), // Keep legacy URL working. "/saveconfig": http.HandlerFunc(ui.saveConfig),
"/saveconfig": http.HandlerFunc(ui.saveConfig), "/deleteconfig": http.HandlerFunc(ui.deleteConfig),
"/deleteconfig": http.HandlerFunc(ui.deleteConfig),
"/download": http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { "/download": http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "application/vnd.google.protobuf+gzip") w.Header().Set("Content-Type", "application/vnd.google.protobuf+gzip")
w.Header().Set("Content-Disposition", "attachment;filename=profile.pb.gz") w.Header().Set("Content-Disposition", "attachment;filename=profile.pb.gz")
p.Write(w) 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 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 // NodeMap maps from a node info struct to a node. It is used to merge
// report entries with the same info. // report entries with the same info.
type NodeMap map[NodeInfo]*Node type NodeMap map[NodeInfo]*Node
@ -583,17 +598,16 @@ func (nm NodeMap) findOrInsertLine(l *profile.Location, li profile.Line, o *Opti
objfile = m.File objfile = m.File
} }
if ni := nodeInfo(l, li, objfile, o); ni != nil { ni := nodeInfo(l, li, objfile, o)
return nm.FindOrInsertNode(*ni, o.KeptNodes)
} return nm.FindOrInsertNode(ni, o.KeptNodes)
return nil
} }
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 { 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, Address: l.Address,
Lineno: int(line.Line), Lineno: int(line.Line),
Columnno: int(line.Column), 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 { if iv, jv := abs64(l.Flat), abs64(r.Flat); iv != jv {
return iv > jv return iv > jv
} }
if iv, jv := l.Info.PrintableName(), r.Info.PrintableName(); iv != jv { equal, leftLess := l.Info.comparePrintableName(r.Info)
return iv < jv if !equal {
return leftLess
} }
if iv, jv := abs64(l.Cum), abs64(r.Cum); iv != jv { if iv, jv := abs64(l.Cum), abs64(r.Cum); iv != jv {
return 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 { if iv, jv := abs64(l.Cum), abs64(r.Cum); iv != jv {
return iv > jv return iv > jv
} }
if iv, jv := l.Info.PrintableName(), r.Info.PrintableName(); iv != jv { equal, leftLess := l.Info.comparePrintableName(r.Info)
return iv < jv if !equal {
return leftLess
} }
return compareNodes(l, r) 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 { if iv, jv := abs64(score[l]), abs64(score[r]); iv != jv {
return iv > jv return iv > jv
} }
if iv, jv := l.Info.PrintableName(), r.Info.PrintableName(); iv != jv { equal, leftLess := l.Info.comparePrintableName(r.Info)
return iv < jv if !equal {
return leftLess
} }
if iv, jv := abs64(l.Flat), abs64(r.Flat); iv != jv { if iv, jv := abs64(l.Flat), abs64(r.Flat); iv != jv {
return iv > jv return iv > jv

View file

@ -159,11 +159,11 @@ type ObjFile interface {
// A Frame describes a location in a single line in a source file. // A Frame describes a location in a single line in a source file.
type Frame struct { type Frame struct {
Func string // name of function Func string // name of function
File string // source file name File string // source file name
Line int // line in file Line int // line in file
Column int // column in line (if available) Column int // column in line (if available)
StartLine int // start line of function (if available) StartLine int // start line of function (if available)
} }
// A Sym describes a single symbol in an object file. // A Sym describes a single symbol in an object file.

View file

@ -36,6 +36,7 @@ package profile
import ( import (
"errors" "errors"
"fmt" "fmt"
"slices"
) )
type buffer struct { 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 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) { func decodeVarint(data []byte) (uint64, []byte, error) {
var u uint64 var u uint64
for i := 0; ; i++ { for i := 0; ; i++ {
@ -286,6 +297,9 @@ func decodeInt64(b *buffer, x *int64) error {
func decodeInt64s(b *buffer, x *[]int64) error { func decodeInt64s(b *buffer, x *[]int64) error {
if b.typ == 2 { if b.typ == 2 {
// Packed encoding // Packed encoding
dataLen := peekNumVarints(b.data)
*x = slices.Grow(*x, dataLen)
data := b.data data := b.data
for len(data) > 0 { for len(data) > 0 {
var u uint64 var u uint64
@ -316,8 +330,11 @@ func decodeUint64(b *buffer, x *uint64) error {
func decodeUint64s(b *buffer, x *[]uint64) error { func decodeUint64s(b *buffer, x *[]uint64) error {
if b.typ == 2 { if b.typ == 2 {
data := b.data
// Packed encoding // Packed encoding
dataLen := peekNumVarints(b.data)
*x = slices.Grow(*x, dataLen)
data := b.data
for len(data) > 0 { for len(data) > 0 {
var u uint64 var u uint64
var err error var err error

View file

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