Skip to content

Phase 6.2: pprof integration test with go tool pprof - #21

Merged
jayakasadev merged 1 commit into
mainfrom
feature/phase-6-2-pprof-roundtrip
Jun 11, 2026
Merged

jayakasadev merged 1 commit into
mainfrom
feature/phase-6-2-pprof-roundtrip

Conversation

@jayakasadev

Copy link
Copy Markdown
Owner

Summary

Validates HeapProfile::write_pprof output is consumable by Google's go 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 pprof cleanly parses zero-sample Profile.
  • Skips gracefully when go not on PATH (skip_if_no_go() probes go version).
  • Zero new deps — stdlib only (std::env::temp_dir + process::id + SystemTime nanos for unique tempfile names, std::process::Command for subprocess).
  • Process-wide OnceLock<Mutex> matches the convention in profile_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

- 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.
@jayakasadev
jayakasadev merged commit 917763e into main Jun 11, 2026
155 of 202 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant