aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/vendor/github.com/google/pprof/internal/driver/fetch.go
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2022-11-22 12:39:05 -0500
committerCherry Mui <cherryyz@google.com>2022-11-22 18:58:12 +0000
commitbb917bd1b212dc8fff3852fa164667cd06b9f653 (patch)
tree36785e58dd168eca8d7001b48dbbed10bdadfe91 /src/cmd/vendor/github.com/google/pprof/internal/driver/fetch.go
parent21015cf6baed45a1e7c3d1a0dfe34c778140344f (diff)
downloadgo-bb917bd1b212dc8fff3852fa164667cd06b9f653.tar.xz
cmd/vendor: update vendored github.com/google/pprof for Go 1.20 release
The Go 1.20 code freeze has recently started. This is a time to update the vendored copy. Done by cd GOROOT/src/cmd go get -d github.com/google/pprof@latest go mod tidy go mod vendor For #36905. Change-Id: Iaec604c66ea8f4b7638a31bdb77d6dd56966e38a Reviewed-on: https://go-review.googlesource.com/c/go/+/452815 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Diffstat (limited to 'src/cmd/vendor/github.com/google/pprof/internal/driver/fetch.go')
-rw-r--r--src/cmd/vendor/github.com/google/pprof/internal/driver/fetch.go21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/cmd/vendor/github.com/google/pprof/internal/driver/fetch.go b/src/cmd/vendor/github.com/google/pprof/internal/driver/fetch.go
index 0b361651bc..5ddee33610 100644
--- a/src/cmd/vendor/github.com/google/pprof/internal/driver/fetch.go
+++ b/src/cmd/vendor/github.com/google/pprof/internal/driver/fetch.go
@@ -18,7 +18,6 @@ import (
"bytes"
"fmt"
"io"
- "io/ioutil"
"net/http"
"net/url"
"os"
@@ -167,7 +166,7 @@ func grabSourcesAndBases(sources, bases []profileSource, fetch plugin.Fetcher, o
// a single profile. It fetches a chunk of profiles concurrently, with a maximum
// chunk size to limit its memory usage.
func chunkedGrab(sources []profileSource, fetch plugin.Fetcher, obj plugin.ObjTool, ui plugin.UI, tr http.RoundTripper) (*profile.Profile, plugin.MappingSources, bool, int, error) {
- const chunkSize = 64
+ const chunkSize = 128
var p *profile.Profile
var msrc plugin.MappingSources
@@ -242,10 +241,22 @@ func concurrentGrab(sources []profileSource, fetch plugin.Fetcher, obj plugin.Ob
func combineProfiles(profiles []*profile.Profile, msrcs []plugin.MappingSources) (*profile.Profile, plugin.MappingSources, error) {
// Merge profiles.
+ //
+ // The merge call below only treats exactly matching sample type lists as
+ // compatible and will fail otherwise. Make the profiles' sample types
+ // compatible for the merge, see CompatibilizeSampleTypes() doc for details.
+ if err := profile.CompatibilizeSampleTypes(profiles); err != nil {
+ return nil, nil, err
+ }
if err := measurement.ScaleProfiles(profiles); err != nil {
return nil, nil, err
}
+ // Avoid expensive work for the common case of a single profile/src.
+ if len(profiles) == 1 && len(msrcs) == 1 {
+ return profiles[0], msrcs[0], nil
+ }
+
p, err := profile.Merge(profiles)
if err != nil {
return nil, nil, err
@@ -410,6 +421,10 @@ mapping:
fileNames = append(fileNames, matches...)
}
fileNames = append(fileNames, filepath.Join(path, m.File, m.BuildID)) // perf path format
+ // Llvm buildid protocol: the first two characters of the build id
+ // are used as directory, and the remaining part is in the filename.
+ // e.g. `/ab/cdef0123456.debug`
+ fileNames = append(fileNames, filepath.Join(path, m.BuildID[:2], m.BuildID[2:]+".debug"))
}
if m.File != "" {
// Try both the basename and the full path, to support the same directory
@@ -507,7 +522,7 @@ func fetchURL(source string, timeout time.Duration, tr http.RoundTripper) (io.Re
func statusCodeError(resp *http.Response) error {
if resp.Header.Get("X-Go-Pprof") != "" && strings.Contains(resp.Header.Get("Content-Type"), "text/plain") {
// error is from pprof endpoint
- if body, err := ioutil.ReadAll(resp.Body); err == nil {
+ if body, err := io.ReadAll(resp.Body); err == nil {
return fmt.Errorf("server response: %s - %s", resp.Status, body)
}
}