golang/go
View on GitHubcmd/compile/internal/pgo: error parsing profile (for pgo) after scaling
Open
#73640 opened on May 8, 2025
BugReportNeedsFixSuggestedcompiler/runtimehelp wanted
Description
Go version
go version go1.24.2 darwin/arm64
Output of go env in your module/workspace:
AR='ar'
CC='cc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='c++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/gopher/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/gopher/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/4x/zvfqpl3d4zx4f7jq76sy_m6r0000gs/T/go-build2991403458=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD=''
GOMODCACHE='/Users/gopher/workspaces/wf/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/gopher/workspaces/wf/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.24.2/libexec'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/gopher/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.24.2/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.24.2'
GOWORK=''
PKG_CONFIG='pkg-config'
What did you do?
I have a profile which I'd like to use for PGO, however it is exceptionally large. I scaled the profile to reduce the size. However after scaling, the profile cannot be used for PGO. I've included an example scaler:
package main
import (
"bytes"
"os"
"time"
"github.com/google/pprof/profile"
)
func main() {
b, err := os.ReadFile(`profile.pb`)
if err != nil {
panic(err)
}
p, err := profile.ParseData(b)
if err != nil {
panic(err)
}
// scale the profile to reduce the size
p.Scale(1 / (float64(time.Millisecond)))
p.Scale(float64(time.Millisecond))
buf := &bytes.Buffer{}
err = p.Write(buf)
if err != nil {
panic(err)
}
os.WriteFile(`scaled.pb`, buf.Bytes(), 0644)
}
I then attempted to use PGO with scaled profile
go build -pgo scaled.pb main.go
What did you see happen?
Received the following error:
preprofile: error parsing profile: profile missing Function.start_line data (Go version of profiled application too old? Go 1.20+ automatically adds this to profiles)
The original profile can be used with pgo, as expected:
go build -pgo profile.pb main.go
What did you expect to see?
I expected both the scaled and non-scaled profiles to be usable for PGO.