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
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=
Address string `json:"Address"`
ModuleName string `json:"ModuleName"`
Symbol []struct {
- Line int `json:"Line"`
- Column int `json:"Column"`
- FunctionName string `json:"FunctionName"`
- FileName string `json:"FileName"`
- StartLine int `json:"StartLine"`
+ Line int `json:"Line"`
+ Column int `json:"Column"`
+ FunctionName string `json:"FunctionName"`
+ FileName string `json:"FileName"`
+ StartLine int `json:"StartLine"`
} `json:"Symbol"`
}
if err := json.Unmarshal([]byte(line), &frame); err != nil {
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"), ",")
</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>
Host: host,
Port: port,
Handlers: map[string]http.Handler{
- "/": 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),
+ "/": 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),
+ "/saveconfig": http.HandlerFunc(ui.saveConfig),
+ "/deleteconfig": http.HandlerFunc(ui.deleteConfig),
"/download": http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "application/vnd.google.protobuf+gzip")
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),
},
}
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
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),
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
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)
},
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
// A Frame describes a location in a single line in a source file.
type Frame struct {
- Func string // name of function
- File string // source file name
- Line int // line in file
- Column int // column in line (if available)
- StartLine int // start line of function (if available)
+ Func string // name of function
+ File string // source file name
+ Line int // line in file
+ Column int // column in line (if available)
+ StartLine int // start line of function (if available)
}
// A Sym describes a single symbol in an object file.
import (
"errors"
"fmt"
+ "slices"
)
type buffer struct {
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++ {
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
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
-# 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