grafana / pyroscope

Continuous Profiling Platform. Debug performance issues down to a single line of code
https://grafana.com/oss/pyroscope/
GNU Affero General Public License v3.0
9.97k stars 597 forks source link

feat: pprof export for Go PGO #3360

Closed kolesnikovae closed 3 months ago

kolesnikovae commented 3 months ago

The PR adds a method to handle pprof queries for Go PGO purposes. The output file is up to 10-100 times smaller in size compared to the full pprof profile (without truncation). Based on the discussion and the snippet by Michael Pratt (Go team).

The PR also extends profilecli: users may query the profile by running:

profilecli query go-pgo --query='{service_name="my-service"}'

I'm going to experiment with it a little more before merging, and update docs and examples. In the meantime, I'm curious what you think about this.

kolesnikovae commented 3 months ago

I compared the number of cases using the PGO debug (-gcflags="-d=pgodebug=2") locally (go version go1.22.3 darwin/arm64). The results are identical for both trimmed and full profiles. So I think it should be used instead of the export via UI

simonswine commented 3 months ago

@kolesnikovae I think we should also expose this via the UI. Ideally I would like to have every feature in the UI and only where it makes sense provide support for profilecli. Do you mind creating an issue in the plugin repo?

kolesnikovae commented 3 months ago

Yeah, that makes sense: https://github.com/grafana/explore-profiles/issues/457. I'm not sure what the UI should look like, though.

I think this specific feature will be primarily used via CLI since it's supposed to be part of the build pipeline.