-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Description
According to the official Go documentation about PGO, the only described way to collect a PGO profile is via https://pkg.go.dev/net/http/pprof and collect the profile from a dedicated HTTP handler.
This way has a major drawback - it's not convenient to collect profiles from non-service-like workloads. E.g. if I have a one-shot system - it is almost not possible to collect a good profile from the application.
As far as I understand, in such cases could be applied tricks from https://pkg.go.dev/runtime/pprof documentation with
manual CPU dumping. This way also has some drawbacks:
- Right now it's not clear - what kind of profile should be collected for the PGO build.
CpuProfile,Memprofile? I guess CpuProfile should be used - A user needs to manually integrate profile collection at exit - it could be an error-prone activity
I suggest an additional way to collect PGO profiles - add a specific "Instrumentation" build for the Go application. This would be very similar to Instrumentation PGO in other languages/compilers like Clang, GCC, Rustc. In the Go application, this specific kind of build will simply insert a code by dumping a PGO profile to a disk at the program exit (like it's done in Clang). This makes it much easier to collect PGO profiles for programs like https://github.com/dominikh/go-tools .
Also, an additional way with auto-dumping makes using PGO in Go easier for people who have PGO experience from other languages like C++ and Rust.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status