pprof-rs icon indicating copy to clipboard operation
pprof-rs copied to clipboard

feat: implement Report::from_pprof() for protobuf roundtrip conversion

Open Benjscho opened this issue 4 months ago • 2 comments

Add backwards conversion from protobuf Profile to Report, enabling roundtrip conversion between the two formats. This allows users to reconstruct Report objects from previously exported protobuf data, which is helpful for making flamegraphs.

Changes:

  • Add Report::from_pprof() method to convert protobuf Profile back to Report
  • Fix pprof() method to create one location per frame instead of per symbol
  • Group inlined functions correctly within locations per pprof spec
  • Add roundtrip conversion test

The changes make the protobuf output more standards-compliant by grouping inlined function symbols within the same location, which aligns with how Google's pprof tool expects the data to be structured.

Benjscho avatar Aug 14 '25 23:08 Benjscho

Welcome @Benjscho! It looks like this is your first PR to tikv/pprof-rs 🎉

ti-chi-bot[bot] avatar Aug 14 '25 23:08 ti-chi-bot[bot]

@YangKeao would you be able to review?

Benjscho avatar Aug 25 '25 16:08 Benjscho