cmd/internal/pgo: accept CPU profiles from external tools like Linux perf - #81104
cmd/internal/pgo: accept CPU profiles from external tools like Linux perf#81104geekswaroop wants to merge 1 commit into
Conversation
…perf
PGO consumes a CPU pprof profile, but FromPProf only accepted the value
types emitted by Go's own runtime/pprof ("samples"/"count" and
"cpu"/"nanoseconds") and rejected everything else with a hard error. This
blocked CPU profiles produced outside the Go runtime, most notably Linux
perf profiles converted with perf_data_converter (perf_to_profile), which
name their sample values after the profiled event (e.g. "cycles_event"/
"count") rather than using Go's names.
Such profiles are still CPU profiles: PGO only reads the selected value as
an edge weight and thresholds it as a fraction of the total, so the value's
name and unit do not affect the result beyond selecting the column. When no
Go-native CPU value type is present, select the column via the profile's
default sample type (falling back to the last value type when unset, per the
pprof format), while still rejecting value types from known non-CPU profiles
(heap, mutex, block) so that passing e.g. a heap profile to -pgo still fails
clearly.
The other blocker noted on the issue, missing Function.start_line in
symbolized perf profiles, was fixed separately in google/pprof and is
already vendored into the toolchain, so no change is needed here for it.
Fixes golang#64489
|
This PR (HEAD: bb77fa4) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/go/+/819781. Important tips:
|
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/819781. |
|
Message from Michael Pratt: Patch Set 1: Commit-Queue+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/819781. |
|
Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com: Patch Set 1: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2026-08-25T16:45:06Z","revision":"23e24126fdd6d53e44288364dea0c596e87f335e"} Please don’t reply on this GitHub thread. Visit golang.org/cl/819781. |
|
Message from Michael Pratt: Patch Set 1: -Commit-Queue (Performed by <GERRIT_ACCOUNT_60063> on behalf of <GERRIT_ACCOUNT_12120>) Please don’t reply on this GitHub thread. Visit golang.org/cl/819781. |
|
Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com: Patch Set 1: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/819781. |
|
Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com: Patch Set 1: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/819781. |
|
Message from Paweł Królikowski: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/819781. |
|
Message from Krishna Swaroop: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/819781. |
PGO consumes a CPU pprof profile, but FromPProf only accepted the value
types emitted by Go's own runtime/pprof ("samples"/"count" and
"cpu"/"nanoseconds") and rejected everything else with a hard error. This
blocked CPU profiles produced outside the Go runtime, most notably Linux
perf profiles converted with perf_data_converter (perf_to_profile), which
name their sample values after the profiled event (e.g. "cycles_event"/
"count") rather than using Go's names.
Such profiles are still CPU profiles: PGO only reads the selected value as
an edge weight and thresholds it as a fraction of the total, so the value's
name and unit do not affect the result beyond selecting the column. When no
Go-native CPU value type is present, select the column via the profile's
default sample type (falling back to the last value type when unset, per the
pprof format), while still rejecting value types from known non-CPU profiles
(heap, mutex, block) so that passing e.g. a heap profile to -pgo still fails
clearly.
The other blocker noted on the issue, missing Function.start_line in
symbolized perf profiles, was fixed separately in google/pprof and is
already vendored into the toolchain, so no change is needed here for it.
Fixes #64489