Phase 6.2: pprof integration test with go tool pprof - #21
Merged
Merged
Conversation
- New snmalloc-rs/tests/profile_pprof_roundtrip.rs (profiling-gated) - `pprof_roundtrip_via_go_tool`: runs a small workload, writes the pprof bytes to a unique tempfile (no `tempfile` dep), and invokes `go tool pprof -raw <file>`. Asserts exit 0 and that stdout contains a structural marker (`Samples:`, `sample_type`, `PeriodType`, or one of our axis names). - `empty_snapshot_pprof_roundtrip`: same path but on a default `HeapProfile`; the metadata-only Profile must still parse. - `skip_if_no_go` helper: probes `go version` and skips with an `eprintln!` when Go is not on PATH. Keeps cargo test green on developer machines / CI images without a Go toolchain. - No new dev-deps; stdlib only. Tempfile path uses `temp_dir() + pid + SystemTime nanos`. - Workload + process-wide mutex pattern mirrors profile_pprof.rs and profile_viewer_roundtrip.rs.
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
Validates
HeapProfile::write_pprofoutput is consumable by Google'sgo tool pprof.pprof_roundtrip_with_go(profiling): real workload →write_pprof→ tempfile →go tool pprof -raw <file>subprocess → assert stdout contains structural markers (Samples:,sample_type,PeriodType,alloc_space,alloc_objects).empty_snapshot_pprof_roundtrip(profiling): empty profile →go tool pprofcleanly parses zero-sample Profile.gonot on PATH (skip_if_no_go()probesgo version).std::env::temp_dir + process::id + SystemTime nanosfor unique tempfile names,std::process::Commandfor subprocess).OnceLock<Mutex>matches the convention inprofile_pprof.rs/profile_viewer_roundtrip.rs.Test plan
cargo test --features profiling --test profile_pprof_roundtrip(2/2 — both skipped on this sandbox via skip_if_no_go since Go not installed)cargo test(no features) — compile-time skip via#![cfg(feature = "profiling")]cargo test --features profiling— full suite green