]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/pprof: update vendored github.com/google/pprof
authorDmitri Shuralyov <dmitshur@golang.org>
Wed, 13 Aug 2025 20:48:59 +0000 (16:48 -0400)
committerGopher Robot <gobot@golang.org>
Wed, 13 Aug 2025 22:06:59 +0000 (15:06 -0700)
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-20250630185457-6e76a2b096b5
go mod tidy
go mod vendor

Change-Id: Icfa35291f629fcffae67238704e59e17ee05e0b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/696015
Reviewed-by: David Chase <drchase@google.com>
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>
21 files changed:
src/cmd/go.mod
src/cmd/go.sum
src/cmd/vendor/github.com/google/pprof/driver/driver.go
src/cmd/vendor/github.com/google/pprof/internal/driver/config.go
src/cmd/vendor/github.com/google/pprof/internal/driver/driver_focus.go
src/cmd/vendor/github.com/google/pprof/internal/driver/fetch.go
src/cmd/vendor/github.com/google/pprof/internal/driver/html/common.css
src/cmd/vendor/github.com/google/pprof/internal/driver/html/stacks.js
src/cmd/vendor/github.com/google/pprof/internal/driver/webui.go
src/cmd/vendor/github.com/google/pprof/internal/elfexec/elfexec.go
src/cmd/vendor/github.com/google/pprof/internal/graph/graph.go
src/cmd/vendor/github.com/google/pprof/internal/measurement/measurement.go
src/cmd/vendor/github.com/google/pprof/internal/report/report.go
src/cmd/vendor/github.com/google/pprof/internal/report/source.go
src/cmd/vendor/github.com/google/pprof/internal/symbolizer/symbolizer.go
src/cmd/vendor/github.com/google/pprof/profile/merge.go
src/cmd/vendor/github.com/google/pprof/profile/profile.go
src/cmd/vendor/github.com/google/pprof/profile/prune.go
src/cmd/vendor/github.com/google/pprof/third_party/svgpan/svgpan.js
src/cmd/vendor/github.com/ianlancetaylor/demangle/demangle.go
src/cmd/vendor/modules.txt

index dcea08e01589e126bb7c8d6e9b93470d4c464282..46630f4ed83f05edbe1f625eef46d6eb7a3c550f 100644 (file)
@@ -3,7 +3,7 @@ module cmd
 go 1.26
 
 require (
-       github.com/google/pprof v0.0.0-20250208200701-d0013a598941
+       github.com/google/pprof v0.0.0-20250630185457-6e76a2b096b5
        golang.org/x/arch v0.20.1-0.20250808194827-46ba08e3ae58
        golang.org/x/build v0.0.0-20250806225920-b7c66c047964
        golang.org/x/mod v0.27.0
@@ -15,7 +15,7 @@ require (
 )
 
 require (
-       github.com/ianlancetaylor/demangle v0.0.0-20240912202439-0a2b6291aafd // indirect
+       github.com/ianlancetaylor/demangle v0.0.0-20250417193237-f615e6bd150b // indirect
        golang.org/x/text v0.28.0 // indirect
        rsc.io/markdown v0.0.0-20240306144322-0bf8f97ee8ef // indirect
 )
index de01e8e294cc5750c74ef03c2c024bb0b697d213..57c506936c4475e08c2b1cbf18e1ad1f612ca1cd 100644 (file)
@@ -1,9 +1,9 @@
 github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
 github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
-github.com/google/pprof v0.0.0-20250208200701-d0013a598941 h1:43XjGa6toxLpeksjcxs1jIoIyr+vUfOqY2c6HB4bpoc=
-github.com/google/pprof v0.0.0-20250208200701-d0013a598941/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144=
-github.com/ianlancetaylor/demangle v0.0.0-20240912202439-0a2b6291aafd h1:EVX1s+XNss9jkRW9K6XGJn2jL2lB1h5H804oKPsxOec=
-github.com/ianlancetaylor/demangle v0.0.0-20240912202439-0a2b6291aafd/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw=
+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/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=
 github.com/yuin/goldmark v1.6.0/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
 golang.org/x/arch v0.20.1-0.20250808194827-46ba08e3ae58 h1:uxPa6+/WsUfzikIAPMqpTho10y4qtYpINBurU+6NrHE=
index 989aac32ffef4cf8ec46fe44083cdbc1b6c4bac9..657a673521442904624e1fca9f37517b98aaa1c2 100644 (file)
@@ -17,6 +17,7 @@ package driver
 
 import (
        "io"
+       "maps"
        "net/http"
        "regexp"
        "time"
@@ -293,8 +294,6 @@ type internalSymbolizer struct {
 
 func (s *internalSymbolizer) Symbolize(mode string, srcs plugin.MappingSources, prof *profile.Profile) error {
        isrcs := MappingSources{}
-       for m, s := range srcs {
-               isrcs[m] = s
-       }
+       maps.Copy(isrcs, srcs)
        return s.Symbolizer.Symbolize(mode, isrcs, prof)
 }
index 090230e2a787752d96902b560f40084be3d875e4..184de397ef57e4af0ee397123472d368faea7716 100644 (file)
@@ -4,6 +4,7 @@ import (
        "fmt"
        "net/url"
        "reflect"
+       "slices"
        "strconv"
        "strings"
        "sync"
@@ -226,11 +227,9 @@ func (cfg *config) set(f configField, value string) error {
        case *string:
                if len(f.choices) > 0 {
                        // Verify that value is one of the allowed choices.
-                       for _, choice := range f.choices {
-                               if choice == value {
-                                       *ptr = value
-                                       return nil
-                               }
+                       if slices.Contains(f.choices, value) {
+                               *ptr = value
+                               return nil
                        }
                        return fmt.Errorf("invalid %q value %q", f.name, value)
                }
index fd05adb1469993d1214ddf576a652768b68c6199..fb9c35c6010730c5876acd8ea7a27a76caeeccf5 100644 (file)
@@ -17,6 +17,7 @@ package driver
 import (
        "fmt"
        "regexp"
+       "slices"
        "strconv"
        "strings"
 
@@ -148,10 +149,8 @@ func compileTagFilter(name, value string, numLabelUnits map[string]string, ui pl
        return func(s *profile.Sample) bool {
                if vals, ok := s.Label[wantKey]; ok {
                        for _, rx := range rfx {
-                               for _, val := range vals {
-                                       if rx.MatchString(val) {
-                                               return true
-                                       }
+                               if slices.ContainsFunc(vals, rx.MatchString) {
+                                       return true
                                }
                        }
                }
index a94ddf6adb71e3839d838d59fe9fbae9250176df..969c1dac11ef357eb21c4389da68fbad639526c0 100644 (file)
@@ -174,10 +174,7 @@ func chunkedGrab(sources []profileSource, fetch plugin.Fetcher, obj plugin.ObjTo
        var count int
 
        for start := 0; start < len(sources); start += chunkSize {
-               end := start + chunkSize
-               if end > len(sources) {
-                       end = len(sources)
-               }
+               end := min(start+chunkSize, len(sources))
                chunkP, chunkMsrc, chunkSave, chunkCount, chunkErr := concurrentGrab(sources[start:end], fetch, obj, ui, tr)
                switch {
                case chunkErr != nil:
index 0a897ce291692799cede5c5662f27cdd2d8d2fcc..8c7693d0a71c9efec26b1e7db5ce6ab1cc44bcf5 100644 (file)
@@ -218,10 +218,12 @@ a {
 }
 #graph {
   overflow: hidden;
+  width: 100%;
+  height: 100%;
 }
 #graph svg {
   width: 100%;
-  height: auto;
+  height: 100%;
   padding: 10px;
 }
 #content.source .filename {
index 7db06996da499c4d025eb6e1fd7fa314f545da5c..8ba2f35c373d8d624e916ac31bdf5fb668147daf 100644 (file)
@@ -579,7 +579,7 @@ function stackViewer(stacks, nodes) {
   }
 
   // percentText returns text that displays v in appropriate units alongside its
-  // percentange.
+  // percentage.
   function percentText(v) {
     function percent(v, total) {
       return Number(((100.0 * v) / total).toFixed(1)) + '%';
index dd628f7c2dd7c32e4261a919d221bf47124fb47a..ac7465c93e6c12a103f08718f6b08809798ebc41 100644 (file)
@@ -19,11 +19,13 @@ import (
        "fmt"
        "html/template"
        "io"
+       "maps"
        "net"
        "net/http"
        gourl "net/url"
        "os"
        "os/exec"
+       "slices"
        "strconv"
        "strings"
        "time"
@@ -107,9 +109,7 @@ func serveWebInterface(hostport string, p *profile.Profile, o *plugin.Options, d
        for n, c := range pprofCommands {
                ui.help[n] = c.description
        }
-       for n, help := range configHelp {
-               ui.help[n] = help
-       }
+       maps.Copy(ui.help, configHelp)
        ui.help["details"] = "Show information about the profile and this view"
        ui.help["graph"] = "Display profile as a directed graph"
        ui.help["flamegraph"] = "Display profile as a flame graph"
@@ -227,12 +227,7 @@ func redirectWithQuery(path string, code int) http.HandlerFunc {
 }
 
 func isLocalhost(host string) bool {
-       for _, v := range []string{"localhost", "127.0.0.1", "[::1]", "::1"} {
-               if host == v {
-                       return true
-               }
-       }
-       return false
+       return slices.Contains([]string{"localhost", "127.0.0.1", "[::1]", "::1"}, host)
 }
 
 func openBrowser(url string, o *plugin.Options) {
index 3f5b09b5e707f86fb180b83e0994ff68e09816d2..37884033d3c8c60beb462c12075786190b088c92 100644 (file)
@@ -230,7 +230,7 @@ func GetBase(fh *elf.FileHeader, loadSegment *elf.ProgHeader, stextOffset *uint6
                }
                if stextOffset == nil && start > 0 && start < 0x8000000000000000 {
                        // A regular user-mode executable. Compute the base offset using same
-                       // arithmetics as in ET_DYN case below, see the explanation there.
+                       // arithmetic as in ET_DYN case below, see the explanation there.
                        // Ideally, the condition would just be "stextOffset == nil" as that
                        // represents the address of _stext symbol in the vmlinux image. Alas,
                        // the caller may skip reading it from the binary (it's expensive to scan
@@ -313,7 +313,7 @@ func ProgramHeadersForMapping(phdrs []elf.ProgHeader, mapOff, mapSz uint64) []*e
                // value is dependent on the memory management unit of the CPU. The page
                // size is 4KB virtually on all the architectures that we care about, so we
                // define this metric as a constant. If we encounter architectures where
-               // page sie is not 4KB, we must try to guess the page size on the system
+               // page size is not 4KB, we must try to guess the page size on the system
                // where the profile was collected, possibly using the architecture
                // specified in the ELF file header.
                pageSize       = 4096
index 8abbd83f76513d9250240cdf016a2b67b7bcde27..c4b0d4869f5316d57a2fa7640ec0b418ffe511d2 100644 (file)
@@ -336,12 +336,8 @@ func newGraph(prof *profile.Profile, o *Options) (*Graph, map[uint64]Nodes) {
                if dw == 0 && w == 0 {
                        continue
                }
-               for k := range seenNode {
-                       delete(seenNode, k)
-               }
-               for k := range seenEdge {
-                       delete(seenEdge, k)
-               }
+               clear(seenNode)
+               clear(seenEdge)
                var parent *Node
                // A residual edge goes over one or more nodes that were not kept.
                residual := false
@@ -850,10 +846,7 @@ func (g *Graph) selectTopNodes(maxNodes int, visualMode bool) Nodes {
                        // If generating a visual graph, count tags as nodes. Update
                        // maxNodes to account for them.
                        for i, n := range g.Nodes {
-                               tags := countTags(n)
-                               if tags > maxNodelets {
-                                       tags = maxNodelets
-                               }
+                               tags := min(countTags(n), maxNodelets)
                                if count += tags + 1; count >= maxNodes {
                                        maxNodes = i + 1
                                        break
index e5b7dbc6c4a88e642b7e1d2a97f182a510cafc12..479235c0a615bdeeb2736e621d159a99ce14f2d0 100644 (file)
@@ -18,6 +18,7 @@ package measurement
 import (
        "fmt"
        "math"
+       "slices"
        "strings"
        "time"
 
@@ -197,16 +198,14 @@ type UnitType struct {
 // nil if the unit with such alias is not found.
 func (ut UnitType) findByAlias(alias string) *Unit {
        for _, u := range ut.Units {
-               for _, a := range u.aliases {
-                       if alias == a {
-                               return &u
-                       }
+               if slices.Contains(u.aliases, alias) {
+                       return &u
                }
        }
        return nil
 }
 
-// sniffUnit simpifies the input alias and returns the unit associated with the
+// sniffUnit simplifies the input alias and returns the unit associated with the
 // specified alias. It returns nil if the unit with such alias is not found.
 func (ut UnitType) sniffUnit(unit string) *Unit {
        unit = strings.ToLower(unit)
index 9d52872b7d438318a9d1cb9da2db9a78ccf8d9ab..ad8b84bf80863850c7b10f76a84da22c830a0690 100644 (file)
@@ -569,7 +569,7 @@ func symbolsFromBinaries(prof *profile.Profile, g *graph.Graph, rx *regexp.Regex
        return objSyms
 }
 
-// objSym represents a symbol identified from a binary. It includes
+// objSymbol represents a symbol identified from a binary. It includes
 // the SymbolInfo from the disasm package and the base that must be
 // added to correspond to sample addresses
 type objSymbol struct {
index d2148607ea2d105959c6908627654102329a0e32..f17952faee1f0afa48fa882eebeaaebd3411bd96 100644 (file)
@@ -25,6 +25,7 @@ import (
        "os"
        "path/filepath"
        "regexp"
+       "slices"
        "sort"
        "strconv"
        "strings"
@@ -490,7 +491,7 @@ func (sp *sourcePrinter) addStack(addr uint64, frames []plugin.Frame) {
                file.lines[f.Line] = append(file.lines[f.Line], sourceInst{addr, stack})
 
                // Remember the first function name encountered per source line
-               // and assume that that line belongs to that function.
+               // and assume that line belongs to that function.
                if _, ok := file.funcName[f.Line]; !ok {
                        file.funcName[f.Line] = f.Func
                }
@@ -553,7 +554,7 @@ func (sp *sourcePrinter) splitIntoRanges(prof *profile.Profile, addrMap map[uint
                        unprocessed = append(unprocessed, addr)
                }
        }
-       sort.Slice(addrs, func(i, j int) bool { return addrs[i] < addrs[j] })
+       slices.Sort(addrs)
 
        const expand = 500 // How much to expand range to pick up nearby addresses.
        var result []addressRange
@@ -769,10 +770,7 @@ func (sp *sourcePrinter) functions(f *sourceFile) []sourceFunction {
                        }
                } else {
                        // Find gap from predecessor and divide between predecessor and f.
-                       halfGap := (f.begin - funcs[i-1].end) / 2
-                       if halfGap > expand {
-                               halfGap = expand
-                       }
+                       halfGap := min((f.begin-funcs[i-1].end)/2, expand)
                        funcs[i-1].end += halfGap
                        f.begin -= halfGap
                }
index 95c15b136655c755199d5dae4f9cf1950ddfdc46..3a279eca753d9251fc02cd7282e72f42744712c2 100644 (file)
@@ -281,14 +281,11 @@ func demanglerModeToOptions(demanglerMode string) []demangle.Option {
        panic(fmt.Sprintf("unknown demanglerMode %s", demanglerMode))
 }
 
-func demangleSingleFunction(fn *profile.Function, options []demangle.Option) {
+func demangleSingleFunction(fn *profile.Function, opts []demangle.Option) {
        if fn.Name != "" && fn.SystemName != fn.Name {
                return // Already demangled.
        }
-       // Copy the options because they may be updated by the call.
-       o := make([]demangle.Option, len(options))
-       copy(o, options)
-       if demangled := demangle.Filter(fn.SystemName, o...); demangled != fn.SystemName {
+       if demangled := demangle.Filter(fn.SystemName, opts...); demangled != fn.SystemName {
                fn.Name = demangled
                return
        }
@@ -296,7 +293,7 @@ func demangleSingleFunction(fn *profile.Function, options []demangle.Option) {
        // OSX has all the symbols prefixed with extra '_' so lets try
        // once more without it
        if strings.HasPrefix(fn.SystemName, "_") {
-               if demangled := demangle.Filter(fn.SystemName[1:], o...); demangled != fn.SystemName {
+               if demangled := demangle.Filter(fn.SystemName[1:], opts...); demangled != fn.SystemName[1:] {
                        fn.Name = demangled
                        return
                }
@@ -306,7 +303,7 @@ func demangleSingleFunction(fn *profile.Function, options []demangle.Option) {
        // already demangled.
        name := fn.SystemName
        if looksLikeDemangledCPlusPlus(name) {
-               for _, o := range options {
+               for _, o := range opts {
                        switch o {
                        case demangle.NoParams:
                                name = removeMatching(name, '(', ')')
index ba4d746407c13375c8e43307eec3f552101d25cb..8a51690be44c59bdd8672f731857ddcfa8ff2752 100644 (file)
@@ -17,6 +17,7 @@ package profile
 import (
        "encoding/binary"
        "fmt"
+       "slices"
        "sort"
        "strconv"
        "strings"
@@ -78,12 +79,10 @@ func Merge(srcs []*Profile) (*Profile, error) {
                }
        }
 
-       for _, s := range p.Sample {
-               if isZeroSample(s) {
-                       // If there are any zero samples, re-merge the profile to GC
-                       // them.
-                       return Merge([]*Profile{p})
-               }
+       if slices.ContainsFunc(p.Sample, isZeroSample) {
+               // If there are any zero samples, re-merge the profile to GC
+               // them.
+               return Merge([]*Profile{p})
        }
 
        return p, nil
index f47a243903e4059116e17668a61bd151a1f7fdbb..43f561d445541542b9ea33209e7e891b7f59ad08 100644 (file)
@@ -24,6 +24,7 @@ import (
        "math"
        "path/filepath"
        "regexp"
+       "slices"
        "sort"
        "strings"
        "sync"
@@ -734,12 +735,7 @@ func (p *Profile) RemoveLabel(key string) {
 
 // HasLabel returns true if a sample has a label with indicated key and value.
 func (s *Sample) HasLabel(key, value string) bool {
-       for _, v := range s.Label[key] {
-               if v == value {
-                       return true
-               }
-       }
-       return false
+       return slices.Contains(s.Label[key], value)
 }
 
 // SetNumLabel sets the specified key to the specified value for all samples in the
@@ -852,7 +848,17 @@ func (p *Profile) HasFileLines() bool {
 // "[vdso]", "[vsyscall]" and some others, see the code.
 func (m *Mapping) Unsymbolizable() bool {
        name := filepath.Base(m.File)
-       return strings.HasPrefix(name, "[") || strings.HasPrefix(name, "linux-vdso") || strings.HasPrefix(m.File, "/dev/dri/") || m.File == "//anon"
+       switch {
+       case strings.HasPrefix(name, "["):
+       case strings.HasPrefix(name, "linux-vdso"):
+       case strings.HasPrefix(m.File, "/dev/dri/"):
+       case m.File == "//anon":
+       case m.File == "":
+       case strings.HasPrefix(m.File, "/memfd:"):
+       default:
+               return false
+       }
+       return true
 }
 
 // Copy makes a fully independent copy of a profile.
index b2f9fd54660d9a55758dc2cd8d05fb27a36fcbc4..7bba31e8ceadc0983d68c54e74f3f943323bdb15 100644 (file)
@@ -19,6 +19,7 @@ package profile
 import (
        "fmt"
        "regexp"
+       "slices"
        "strings"
 )
 
@@ -40,13 +41,7 @@ func simplifyFunc(f string) string {
        // Account for unsimplified names -- try  to remove the argument list by trimming
        // starting from the first '(', but skipping reserved names that have '('.
        for _, ind := range bracketRx.FindAllStringSubmatchIndex(funcName, -1) {
-               foundReserved := false
-               for _, res := range reservedNames {
-                       if funcName[ind[0]:ind[1]] == res {
-                               foundReserved = true
-                               break
-                       }
-               }
+               foundReserved := slices.Contains(reservedNames, funcName[ind[0]:ind[1]])
                if !foundReserved {
                        funcName = funcName[:ind[0]]
                        break
index 2c4951ecd30f4802e057b948cdd634e4b70e75da..dda7f0f0417b187a0bcbd06fd3f3b2de6b93cfa4 100644 (file)
@@ -3,7 +3,7 @@
  * ======================
  *
  * Given an unique existing element with id "viewport" (or when missing, the 
- * first g-element), including the the library into any SVG adds the following 
+ * first g-element), including the library into any SVG adds the following 
  * capabilities:
  *
  *  - Mouse panning
index dc238e07734d270df907a7c775ae1a87d862f949..b812d35ac2db9e2903292fd705307a4daab1ecba 100644 (file)
@@ -186,7 +186,7 @@ func ToAST(name string, options ...Option) (AST, error) {
                i := 0
                for i < len(options) {
                        if options[i] == NoParams {
-                               options = append(options[:i], options[i+1:]...)
+                               options = append(options[:i:i], options[i+1:]...)
                        } else {
                                i++
                        }
index 964a4ffa629edb9729988f2c303a47cc3c8f2ee1..457fc9d619f6cab42dc4c255f6d136c8fbb7ad4b 100644 (file)
@@ -1,5 +1,5 @@
-# github.com/google/pprof v0.0.0-20250208200701-d0013a598941
-## explicit; go 1.22
+# github.com/google/pprof v0.0.0-20250630185457-6e76a2b096b5
+## explicit; go 1.23.0
 github.com/google/pprof/driver
 github.com/google/pprof/internal/binutils
 github.com/google/pprof/internal/driver
@@ -13,7 +13,7 @@ github.com/google/pprof/internal/symbolz
 github.com/google/pprof/internal/transport
 github.com/google/pprof/profile
 github.com/google/pprof/third_party/svgpan
-# github.com/ianlancetaylor/demangle v0.0.0-20240912202439-0a2b6291aafd
+# github.com/ianlancetaylor/demangle v0.0.0-20250417193237-f615e6bd150b
 ## explicit; go 1.13
 github.com/ianlancetaylor/demangle
 # golang.org/x/arch v0.20.1-0.20250808194827-46ba08e3ae58