Skip to content

feat(linux): support frame-pointer-only recording - #12

Open
not-matthias wants to merge 3 commits into
codspeedfrom
cod-3861-support-samply-fp-unwinding
Open

not-matthias wants to merge 3 commits into
codspeedfrom
cod-3861-support-samply-fp-unwinding

Conversation

@not-matthias

@not-matthias not-matthias commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

TLDR: Add samply record --unwinding-mode fp to use kernel frame-pointer callchains without copying user stacks or registers (Linux only).

  • Keep dwarf as the default with the existing kernel-FP fallback; preserve FP mode for launch, PID attach, and software-event fallback.
  • Fix perf flag ordering so kernel callchains remain excluded when kernel sampling is disabled.
  • Add eight behavior tests for CLI selection, frame ordering, context transitions, and leaf/empty callchains. cargo test -p samply --locked: 28 passed, one existing ignored test.
  • Live recording of a frame-pointer-enabled C workload verified launch, attach, software fallback, and default recording. Syscall traces confirmed FP mode omits stack/register capture; caller chains had no duplicate frames.
  • Fix the macOS startup race exposed by the existing dsymutil CI test: keep accepted processes suspended until their initial threads and libraries have been read.

FP stacks require preserved frame pointers throughout the call chain and remain subject to kernel/architecture support and callchain depth limits.

Refs COD-3861.

Add --unwinding-mode fp to record kernel callchains without copying user stacks or registers. Keep the existing DWARF recording behavior as the default, including on Android.

Apply kernel callchain exclusion after initializing perf flags. Cover CLI selection and callchain-only stack conversion, and document frame-pointer build requirements.
Wait for the sampler to finish task initialization before releasing the preload handshake or resuming an attached task. Otherwise short-lived root processes can exit while their initial threads and libraries are still being read, causing the sampler to panic.

Reuse one rendezvous channel for task initialization. Release the accepter after each initialization attempt, including failures, so processes do not remain suspended when sampling stops.
The user stack copied per sample for DWARF unwinding was fixed at 32000 bytes. Expose it as --unwinding-stack-size (default unchanged) so callers can trade profile size for deeper stacks. Values are validated against the kernel's sample_stack_user constraints (8-byte aligned, below 65536).
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