capture_pid

Function capture_pid 

Source
pub fn capture_pid(pid: i32) -> CtprofSnapshot
Expand description

Capture a ctprof snapshot scoped to a single tgid.

Walks /proc/<pid>/task for thread enumeration but skips every other tgid on the host, sidestepping the wall-clock cost (and blast-radius) of the global probe pass that capture runs. Probes the target tgid’s jemalloc TSD counters when it is jemalloc-linked and not the calling process; otherwise the per-thread allocated / deallocated fields land at zero per the best-effort capture contract.

Useful for tests and tools that already know which process they care about — the resulting snapshot’s threads vec only carries entries for pid’s tgid (one entry per thread of that process). host and cgroup_stats populate normally so the snapshot stays self-describing.