Skip to content

feat: strip capture-machinery frames in pprof encoder - #2

Merged
rupert648 merged 1 commit into
mainfrom
feat/encoder-frame-stripping
May 21, 2026
Merged

rupert648 merged 1 commit into
mainfrom
feat/encoder-frame-stripping

Conversation

@rupert648

Copy link
Copy Markdown
Owner

Summary

  • Moves MACHINERY_NEEDLES / is_machinery into the core culpert crate (pprof.rs) so frame filtering happens at encode time, not just in CLI display
  • backtrace::trace, culpert::sampler, alloc::raw_vec:: and similar internal frames are now absent from the emitted .pb.gz — stock go tool pprof / pprof -text shows real user code at the leaf without any scaffolding
  • Samples whose entire stack is machinery frames are preserved (bytes intact) but emitted with an empty location_id list rather than dropped
  • CLI's format_leaf_callsite and its own copy of MACHINERY_NEEDLES are kept as-is for backward compatibility with existing profiles on disk

Test plan

  • pprof::tests::machinery_frames_stripped_from_encoder — verifies machinery frame names don't appear in any encoded Function; verifies user frames survive
  • pprof::tests::all_machinery_stack_emits_empty_location_list — verifies all-machinery stack emits the sample with correct byte count but zero locations
  • All existing unit + integration tests pass (cargo test --workspace)
  • cargo clippy --all-targets --all-features clean
  • cargo fmt --all clean

🤖 Generated with Claude Code

@rupert648
rupert648 force-pushed the feat/encoder-frame-stripping branch from bf8717d to 292afe8 Compare May 21, 2026 21:16
@github-actions

github-actions Bot commented May 21, 2026 •

Copy link
Copy Markdown

culpert: allocation diff

  • before: /tmp/culpert-baseline.pb.gz — total 12.02 MB (estimated)
  • after: /tmp/example-macros.pb.gz — total 12.09 MB (estimated)
  • net Δ: +67.97 KB (+0.55%)
  • sample rate: 4.00 KB/alloc
  • filter: show changes ≥ 1.00 MB AND ≥ 10.00%

Regressions

None.

Improvements

None.

2 span(s) suppressed by thresholds.

`backtrace::trace`, `culpert::sampler`, `alloc::raw_vec::` and similar
internal frames are now filtered out during pprof encoding, not only in
the `culpert report` CLI display path. Stock `go tool pprof` / `pprof
-text` now shows real user code at the leaf without any culpert scaffolding.

If an entire stack consists of machinery frames the sample is still
emitted (bytes are preserved) but with an empty location_id list, rather
than being silently dropped.

`MACHINERY_NEEDLES` and `is_machinery` are pub in `culpert::pprof`; the
CLI now imports them directly instead of maintaining a duplicate copy.

Two new unit tests cover these cases.
@rupert648
rupert648 force-pushed the feat/encoder-frame-stripping branch from 292afe8 to 6b730c6 Compare May 21, 2026 21:18
@rupert648
rupert648 merged commit 6454d13 into main May 21, 2026
3 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