felixge / pprofutils

MIT License
137 stars 17 forks source link

pprof to `flamebearer` conversion? #11

Open sumerc opened 10 months ago

sumerc commented 10 months ago

Currently, https://pkg.go.dev/github.com/grafana/pyroscope/pkg/og/structs/flamebearer/convert#PprofToProfile supports this kind of conversion, but it is only available in v1.0 and requires whole grafana/pyroscope pkg. I am thinking to do the conversion without any dependency by converting pprof to a tree and then doing level order traversal to calculate the x-offsets. You can see the details of flamebearer format.

It will not be an easy-peasy one, but would you be interested in such conversion? I was going to implement this on a separate repo but then I thought here might actually be better? WDYT?

felixge commented 10 months ago

I'm open to pull requests adding new tools to this package. I can't promise I'll be able to to any maintenance in case of future bug reports, but I have no problem with hitting the merge button on anything that comes my way :).

I'm not familiar with the flamebearer format. Could you clarify if it's specific to Grafana, or if it's defined by this tool?

but it is only available in v1.0 and requires whole grafana/pyroscope pkg

Could you explain why this is a problem for your use case?

Anyway, feel free to send a PR.

sumerc commented 10 months ago

I can't promise I'll be able to to any maintenance in case of future bug reports, but I have no problem with hitting the merge button on anything that comes my way :)

Fair enough :)

Could you clarify if it's specific to Grafana

It is Grafana's format. The other tool is I guess just a name coincidence. There is even a pkg from Grafana that supports this conversion: https://pkg.go.dev/github.com/grafana/pyroscope@v1.0.0/pkg/og/structs/flamebearer, but like I said, it is only available on version 1.0 and is not available on newer versions. So, it is kind of unmaintained.

Could you explain why this is a problem for your use case?

With this conversion, you can render any pprof using https://www.npmjs.com/package/@pyroscope/flamegraph. The UI is pretty amazing IMHO, once you have the flamebearer format. There is even an example repo: https://github.com/pyroscope-io/flamegraph-renderer-example.

Additional note: flamebearer supports diff'ing two different profiles.