Phase 6.1: Rust HeapProfile::write_pprof + hand-rolled pprof proto encoder - #18
Merged
Merged
Conversation
- New pub(crate) module snmalloc-rs/src/pprof.rs hand-rolls the protobuf3 wire format (varint + length-delimited) for the subset of Google's pprof Profile schema needed for snmalloc heap snapshots; no prost/flate2 dependencies added. - HeapProfile::write_pprof emits two sample_type axes (alloc_objects/count, alloc_space/bytes) plus per-stack location/function chains; output is uncompressed (callers can wrap in GzEncoder if they want .pb.gz). - Unsymbolicated frames render function name as 0x..hex.. with empty filename/line, mirroring write_flamegraph; symbolicated frames use names from HeapProfile::symbolize when available. - Tests: 6 unit tests in src/pprof.rs (varint, empty profile, alloc_space-axis invariance under both Weight projections, function/location dedup, string-table slot-0 contract) + 3 integration tests in tests/profile_pprof.rs gated on --features profiling (smoke, empty snapshot, total_weight == total_allocated_bytes).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds pprof output format to
snmalloc-rs. Consumable bygo tool pprof, Pyroscope, Polar Signals, Speedscope (via pprof importer).HeapProfile::write_pprof<W>(w, weight)— emits aProfileproto withsample_type=[("alloc_objects","count"),("alloc_space","bytes")], one sample perBtSample, unique location + function per PCpprof) — zero new deps. Rationale: theProfilemessage is small (~10 fields, two wire types); pullingprost + prost-build + syn + quotefor one message wasn't worth it. ~250 LOC encoder + ~250 LOC tests.flate2::GzEncoderfor.pb.gzif desired."0x{hex}", file empty, line 0. Symbolicated path comes from Phase 4.4'ssymbolicatefeature.Test plan
cargo build(no features)cargo build --features profilingcargo build --features 'profiling symbolicate'cargo test --features profiling: 3 new tests intests/profile_pprof.rs— write_pprof_smoke / write_pprof_empty_snapshot / pprof_total_weight_matches_total_allocated_bytespprof::tests::*unit tests (round-trip decode via minimal in-test decoder, no prost dev-dep)