Skip to main content

xprobe

Minimizing friction on the path to RSI.

xprobe (v0.7.0) is a live Linux CPU, CPython, syscall, and CUDA profiler built for AI agents and performance engineers — emitting strict JSON and raw JSONL from eBPF, perf, external CPython memory reading, and CUPTI on one shared timeline.

CI Latest release License CUDA 12.x | 13.x

Live xprobe captures align a GPU idle bubble with Python GIL stacks on CLOCK_MONOTONIC, feed JSONL into an agent script, and verify an RSI optimization loopLive xprobe captures align a GPU idle bubble with Python GIL stacks on CLOCK_MONOTONIC, feed JSONL into an agent script, and verify an RSI optimization loop

Illustrative RSI loop: live GPU bubble + Python GIL capture aligned on CLOCK_MONOTONIC, sliced in JSONL, patched, and re-verified.

Why xprobe?​

Traditional profilers are built for human eyes and GUIs: bulky traces, slow exports, heavy overhead, and noise that burns an agent's context window. Recursive self-improvement (RSI) needs the opposite — a live, low-friction sensor that emits compact, script-ready data on one shared timeline and turns profiling into a fast, honest feedback loop.

Capabilityxprobeperf / uprobepy-spynsystorch.profiler
Live attach to running processes (no launch wrapper)✅1✅✅⚠️❌
CPU + CPython GIL + syscall + CUDA on one CLOCK_MONOTONIC✅❌❌⚠️⚠️
Wait & trigger on rare GPU idle bubbles / stream gaps / spikes✅❌❌❌❌
Direct JSON / JSONL output for one-off scripts & RSI loops✅❌⚠️❌⚠️
Multi-process & multi-GPU timeline alignment / rank budgets✅⚠️❌✅⚠️
Visual GUI / kernel roofline & hardware counters❌2❌❌✅✅
  1. CPU, CPython stacks/GIL, syscalls, uprobes, and CUDA kernels/copies/APIs attach live; NVTX ranges require NVTX_INJECTION64_PATH before the first NVTX call.
  2. Once a bottleneck is isolated inside a single GPU kernel or needs GUI inspection, hand off to ncu or nsys.

Core Design Concepts​

This section expands on the architectural ideas behind xprobe so you can compose custom measurements and analysis scripts without being limited to canned examples.

1. Stateless, Daemon-less Sensor​

xprobe exposes four public commands (doctor, discover, validate, measure), with no daemon and no persistent session service. Each foreground measure owns attachment, collection, correlation, logical CUPTI stop, and cleanup.

  • Read-only validation: validate never mutates a target; only measure injects CUPTI via ptrace when required, logging the mutation on stderr and in JSON.
  • Logical stop, never dlclose: stopping disables CUPTI callbacks and activity while leaving libxprobe-cupti.so mapped for safe reuse.

2. One Shared Timeline: CLOCK_MONOTONIC + UTC Anchors​

Every aligned collector on a host shares kernel CLOCK_MONOTONIC nanoseconds:

  • Host eBPF events (uprobes, syscalls, tracepoints, CPython GC USDT) use host_monotonic.
  • External CPython samples (--python-sample) emit CLOCK_MONOTONIC timestamp_ns.
  • Normalized CUPTI activity uses cupti_normalized_to_host_monotonic.
  • Every Event JSONL is paired with <artifact>.manifest.json, carrying wall_clock UTC anchors (monotonic_ns, realtime_ns, uncertainty_ns) and cuda_devices physical GPU UUIDs.

That enables direct joins across sources (GPU idle bubble + concurrent Python GIL stacks), across processes or multi-GPU ranks on one host (grouped by physical GPU UUID regardless of CUDA_VISIBLE_DEVICES), and against external UTC application logs.

3. Composable Primitives Over Fixed Playbooks​

Performance bottlenecks vary, so xprobe deliberately avoids prescribing a fixed investigation procedure. Instead, it provides orthogonal building blocks you can combine freely:

AxisPrimitives
Observation sourcesNative ELF functions (uprobe / C++ symbol= / +0x offset), Linux syscall / tracepoint, external CPython 3.9–3.14 stacks & GIL (--python-sample), CPython GC USDT, CPU perf callchains (--cpu-sample), CUDA Runtime/Driver APIs (cuda:launch_api), GPU kernel/memcpy/memset, ASCII NVTX, procfs/cgroup/NVML
Capture shapesExact A → B pairs (--from/--to + 5 --match policies), 1–8 edge measurement graphs (--spec), low-overhead aggregates (--aggregate / --syscall-aggregate / --cpu-sample), ring-buffered triggers (--trigger-idle-ms / -gap-ms / -duration-ms / -latency-ms), same-window snapshot (--triage), offline re-correlation (--input)
Post-capture compositionPiped strict JSON (jq/Python), analyze_trace.py interval unions and vertical slices, cross-process CLOCK_MONOTONIC joins, wall_clock log alignment, repeatable --spec RSI before/after diffs

Examples of diverse compositions (as inspiration, not rules):

  • Run --trigger-idle-ms 10 on a GPU worker concurrently with --python-sample on the same worker or an API process, then slice the Python stacks around the triggered bubble's CLOCK_MONOTONIC window.
  • Capture request → launch_api → kernel_start → kernel_end in one 1–8 edge measurement graph, then re-correlate the saved Event JSONL offline with measure --input for additional hypotheses.
  • Run concurrent stream-order captures across multi-GPU ranks and compare shared-window compute_share, communication_only, and idle budgets with analyze_trace.py rank0.jsonl rank1.jsonl ....
  • Pin a fixed --spec JSON before and after each optimization candidate in an RSI loop, guarding every comparison on ok, zero drops, and quality.verdict.

4. Honest Accounting & Explicit Failures​

Rather than silently dropping events or mixing unaligned clocks, xprobe fails explicitly with structured JSON errors (code, message, details, hints) while preserving written artifacts whenever possible:

  • Cross CPU/GPU subtraction enforces runtime clock alignment and returns CLOCK_ALIGNMENT_FAILED instead of mixing unaligned clocks (GPU-only spans remain usable in raw cupti time).
  • Process identity is checked via (pid, procfs start_time) around inspection and attach (TARGET_EXITED / TARGET_REUSED).
  • A single-stream gap is not device idle time, and summed concurrent kernel durations are not wall time. Manifest all_gpu_activity explicitly marks when device-wide idle math is valid.

Quick Examples​

# 1. Sample CPython 3.9–3.14 stacks & GIL holder from outside the process (no -X perf)
xprobe measure --pid 4242 --python-sample --duration-ms 2000

# 2. Aggregate GPU kernels or memcpy (including pageable vs pinned transfers)
xprobe measure --pid 4242 --from cuda:kernel_start --to cuda:kernel_end \
--match exact --aggregate --duration-ms 2000

# 3. Measure exact launch-to-kernel latency (or up to 8 edges via --spec graph.json)
xprobe measure --pid 4242 --from cuda:launch_api:exit \
--to 'cuda:kernel_start:name~flash.*' --match exact --samples 200

# 4. Wait for a rare >=10 ms GPU idle bubble and keep ±50 ms of context around it
xprobe measure --pid 4242 --trigger-idle-ms 10 --pre-ms 50 --post-ms 50 \
--timeout-ms 300000 --events-out spikes

Pipe into scripts & RSI loops:

before=$(xprobe measure --spec kernel.json | jq '.measurement.latency_ns.p95')
# ... apply kernel / runtime change ...
after=$(xprobe measure --spec kernel.json | jq '.measurement.latency_ns.p95')

skills/xprobe-perf-profiling/scripts/analyze_trace.py trace.jsonl --slice-gap 1 --python-samples py.jsonl
skills/xprobe-perf-profiling/scripts/analyze_trace.py rank0.jsonl rank1.jsonl rank2.jsonl rank3.jsonl

Support Matrix​

SurfaceSupport
PlatformLinux x86_64, glibc ≥ 2.34, CUDA/CUPTI 12.x & 13.x
PythonExternal CPython 3.9–3.14 stacks, GIL holder, blocked native waits, and GC USDT
CPU & LinuxPID-scoped perf callchains (ELF + perf-map), uprobes (symbol/C++/offset), syscalls, tracepoints
GPU & CUDARuntime/Driver APIs (cuda:launch_api), kernels, memcpy (pageable/pinned), memset, ASCII NVTX
ModesExact pairs, 8-edge measurement graphs, coarse aggregates, triggered ring capture, --triage snapshot, offline --input
Correlationexact, stack-nested, stream-order, first-after, nearest

Documentation Map​

  • Installation — PyPI wheel, standalone archive, SHA-256 / SBOM / attestation, Agent Skill, and doctor.
  • CLI Reference — option-by-option flags, types, defaults, mutual exclusions, mode matrix, env vars, exit codes, and all 24 error codes.
  • JSON Interfaces & Schemas — field-by-field input specs, stdout responses, shared enums, and all 26 JSON Schemas.
  • Selectors, Policies & Limits — full selector syntax, symbol/offset resolution, match policies, specs, filter pushdown, and overhead limits.
  • Data Format, Clocks & Scripting — stdout/artifact paths, real JSONL shapes, manifest, clock math, analyze_trace.py, scripting recipes, and all 26 JSON Schemas.
  • Agent Integration — official Skill, command-to-evidence table, hard constraints, and automated verification.
  • Benchmarks — observed overheads and reproducible benchmark suites.
  • Architecture / CUPTI Agent / Development & Releasing — internals, ABI, hardware tests, and release process.