Agent Integration
xprobe exposes four CLI commands, versioned JSON/JSONL, 26 JSON Schemas, and one official Agent Skill. It does not call model APIs or run a daemon.
The canonical Skill lives at skills/xprobe-perf-profiling/SKILL.md. AGENTS.md, CLAUDE.md, and .cursor/rules/xprobe.mdc point to it without duplicating command lists or schema rules.
Install the Skill
The Skill follows the open Agent Skills format and works with Codex, Claude Code, Cursor, and compatible clients:
npx skills add itdevwu/xprobe
To pin a release or install non-interactively, see Installation — AI Agent Skill. Keep the full directory intact so references/, examples/, and scripts/analyze_trace.py remain available.
Skill boundaries
xprobe-perf-profiling intentionally avoids prescribing a fixed investigation procedure. It focuses on what agents need to get right on the first try:
- Command-to-evidence mapping: what each command and mode produces.
- Exact artifact shapes: stdout keys, real JSONL line shapes, pairing keys, and clock conversion math (
references/data-format.md). - Selector syntax & overhead limits: filter pushdown rules and high-rate bounds (
references/selectors.md). - Hard runtime constraints & accounting traps: namespace/ptrace/NVTX prerequisites, and keeping stream gaps distinct from device idle time.
Command-to-evidence lookup
| Need | Command |
|---|---|
| Check eBPF, ptrace, NVIDIA, CUDA/CUPTI | xprobe doctor |
| List CUDA context holders under a PID | xprobe discover --pid "$ROOT" |
| Dry-run selectors, symbols, or injection | xprobe validate --pid "$PID" --from A --to B --match exact |
| Python stacks & GIL holder (CPython 3.9–3.14) | xprobe measure --pid "$PID" --python-sample --duration-ms 2000 |
| Native CPU callchain hotspots | xprobe measure --pid "$PID" --cpu-sample --duration-ms 2000 |
| Syscall count & duration totals | xprobe measure --pid "$PID" --syscall-aggregate --duration-ms 2000 |
| GPU kernel / memcpy / memset totals | xprobe measure --pid "$PID" --from cuda:kernel_start --to cuda:kernel_end --match exact --aggregate --duration-ms 2000 |
| Exact A → B latency (with Event JSONL) | xprobe measure --pid "$PID" --from cuda:launch_api:exit --to cuda:kernel_start --match exact --samples 200 |
| Full GPU timeline / stream gaps / idle | xprobe measure --pid "$PID" --from cuda:kernel_end --to cuda:kernel_start --match stream-order --duration-ms 2000 --events-out trace.jsonl |
| Up to 8 edges in one capture | xprobe measure --spec graph.json |
| Wait for rare GPU bubble / gap / spike | xprobe measure --pid "$PID" --trigger-idle-ms 10 --pre-ms 50 --post-ms 50 --events-out spikes |
| Re-correlate a saved Event JSONL offline | xprobe measure --input trace.jsonl --from A --to B --match exact |
| Same-window cgroup / thread / NVML snapshot | xprobe measure --pid "$PID" --triage --duration-ms 2000 |
With
--triage, read the raw inline inventories (threads,cgroup,gpu_devices,cpu_hotspots,python_hotspots,syscalls,gpu_activity) rather than relying on its staticfindingsranking.
Hard constraints
- Containers & namespaces: a host process cannot inject CUPTI into a container with a different mount namespace; run
xprobeinside the target's PID and mount namespaces. - CUDA injection & NVTX: live CUDA capture attaches via ptrace and leaves the CUPTI
.somapped (logically disabled after stop). NVTX ranges requireNVTX_INJECTION64_PATHset before the target's first NVTX call. - Process discovery:
discoverlists NVML CUDA context holders only; locate pure CPU/Python/gateway PIDs withpsor workload metadata. - Flag bounds: live
measurerequires--samplesor--duration-ms. Inventory modes (--aggregate,--cpu-sample,--python-sample,--syscall-aggregate,--triage) accept--duration-msonly. - Cross-process & clocks: run concurrent
xprobe measure --pid ...commands to profile multiple processes or ranks. On one host,host_monotonic,cupti_normalized_to_host_monotonic, and Python sampletimestamp_nsshareCLOCK_MONOTONICand join directly in Python oranalyze_trace.py. Never pass mixed-PID artifacts tomeasure --input, and never subtract rawcuptitimestamps from host timestamps. - Accounting: a single-stream gap is not GPU idle time, and summed concurrent kernel durations are not wall time. Always check
quality.verdict,dropped, andall_gpu_activitybefore acting on numbers.
Automated checks
just test-agent-contract
just test-skill-install
test-agent-contract verifies that the public CLI is exactly doctor, discover, validate, and measure, invokes them in JSON mode, checks all 26 JSON Schemas, runs the analyze_trace.py fixture suite, and validates the Skill (word budget, links, no orphaned references, documented xprobe flags against --help, cited artifact fields against schemas/, valid JSON blocks, and example specs). test-skill-install runs the skills CLI in isolated home directories and checks byte-for-byte copies for Codex, Claude Code, and Cursor.