Skip to main content

Architecture

How xprobe is structured and how data moves through it.

Overview​

human or AI agent
|
| doctor | discover | validate | measure
| versioned JSON + raw JSONL
v
xprobe CLI
|
+-- core: procfs identity, ELF/symbol/layout resolution, validation, ptrace injection, clock anchors
+-- collector: PID-scoped eBPF, perf CPU sampling, external CPython reading, CUPTI Agent control & ABI
+-- correlator: pairing policies, span evaluation, statistics, quality verdicts
+-- exporter: Event JSONL, capture manifests, Chrome Trace Event Format
v
live Linux process or saved capture files

xprobe has no daemon and no persistent session API. Each foreground measure owns attachment, collection, correlation, logical CUPTI stop, and cleanup.

Workspace layout​

PathRole
xprobe/cliPublic commands (doctor, discover, validate, measure), rendering, exit codes, orchestration
xprobe/coredoctor, process identity, discover, ELF/USDT/Python layout resolution, validate, ptrace injection, wall-clock anchoring, triage rules
xprobe/protocolStrict serde types and generated JSON Schemas (schemas/)
xprobe/collectoreBPF uprobes/syscalls/tracepoints/USDT, perf CPU sampling, external CPython sampling, CUPTI control protocol & ABI decoding
xprobe/correlatorPairing policies, trigger span evaluation, statistics, quality verdicts
xprobe/exporterEvent JSONL, .manifest.json, and Chrome Trace Event Format
bpf/PID-scoped eBPF programs (uprobe, USDT, syscall, tracepoint, syscall aggregate)
cupti/Reusable in-process CUPTI callback, activity, ring, and aggregate Agent (libxprobe-cupti.so)

Process identity and discovery​

  • Target processes are identified by (pid, /proc/<pid>/stat start_time) and re-verified around metadata inspection and attach. Reuse returns TARGET_REUSED; exit returns TARGET_EXITED.
  • discover --pid ROOT queries NVML for compute processes, verifies ancestry under ROOT, and returns confirmed CUDA context holders with process identity, parent PID, command line, and GPU UUIDs.
  • Multi-process and multi-GPU runs invoke one measure per PID; concurrent captures on the same host share CLOCK_MONOTONIC (and map GPUs by UUID via cuda_devices), while CLI correlation stays single-process.

Symbol, probe, and layout resolution​

  • Native ELF: converts ELF virtual addresses through load segments to file offsets, then through /proc/<pid>/maps to runtime addresses (supporting executables, PIE, and shared libraries). Plain names match raw ELF symbols; C++ symbol= checks exported dynamic symbols first and falls back to the full symbol table.
  • CPU stacks: resolves sampled instruction pointers from mapped ELF load segments and text-symbol tables (only loading modules that appear in samples). CPython frames are resolved separately from /tmp/perf-<pid>.map when active; native frames remain available otherwise.
  • CPython GC: parses .note.stapsdt in the mapped interpreter or libpython and requires both python:gc__start and python:gc__done markers in one ELF.
  • External CPython layout: built-in CPython 3.9–3.14 interpreter offsets are checked against _Py_DebugOffsets on 3.13+.

Validation​

validate is read-only. It resolves host/USDT/syscall probes, parses tracepoint and CUDA selectors, checks policy compatibility, and reports required capabilities. CUPTI activation is one of not_required, already_loaded, injection_required (target_mutation: true + TARGET_PROCESS_WILL_BE_MODIFIED), or startup_required (NVTX selector without preloaded Agent — fails explicitly).

Collection paths​

Host eBPF (bpf/, xprobe/collector)​

  • Uprobes: one PID-scoped uprobe/uretprobe per unique endpoint.
  • Syscalls: shared raw sys_enter/sys_exit links filtering PID and up to two x86_64 syscall numbers before reading the six scalar ABI registers (entry) and return value (exit). Pointer arguments are never dereferenced.
  • Tracepoints & CPython GC USDT: record identity and timestamps only; both endpoint links attach before arming so setup events cannot leak in.
  • Syscall aggregate: PID-filtered raw entry/exit programs aggregating into a fixed LRU in-flight map and per-CPU hash map, merged in userspace with selector hints.
  • Rust ownership detaches all links on every return path.

CPU and external Python sampling​

  • --cpu-sample: opens software CPU-clock perf events per target thread, groups exact raw callchains before top-group truncation, and resolves native ELF + optional /tmp/perf-<pid>.map frames while keeping loss, truncation, and symbol-coverage counters visible.
  • --python-sample: reads CPython 3.9–3.14 interpreter memory from outside the target via process_vm_readv (no perf events, eBPF, -X perf, or injection; needs ptrace access). Samples the GIL holder at --python-hz (default 2000) and all threads at --python-threads-hz (default 100), discarding inconsistent reads and reading /proc/<pid>/task/<tid>/syscall for blocked threads' native waits.

CUDA / CUPTI (cupti/, xprobe/collector/src/cupti.rs)​

  • Separate libxprobe-cupti.so builds link libcupti.so.12 and libcupti.so.13 from one source and ABI.
  • Control protocol v6 sends ARM, SNAPSHOT, STOP, and CLOSE over a mode-0600 Unix socket with up to eight endpoint filters and three capture modes (Exact, Aggregate, Ring).
  • Online injection uses Linux x86_64 ptrace (same mount namespace required) to remotely call malloc, free, dlopen, dlsym, and xprobe_cupti_agent_start, restoring registers and touched stack words on every path. STOP/CLOSE disable CUPTI logically without ever calling dlclose.
  • See CUPTI Agent and Online Injection for ABI and lifecycle details.

Triage snapshot (--triage)​

Runs procfs schedstat, cgroup cpu.stat, CPU sampling, external Python sampling (when CPython), syscall aggregate, NVML device health, and CUDA kernel aggregate concurrently in one window. Each full inventory is written to its own artifact; rule-based findings in xprobe/core/src/triage.rs are optional hints over those summaries.

Correlation, manifests, and schemas​

Single-edge and measurement-graph live runs share one capture loop (attach, poll, timeout, CUPTI stop, cleanup, artifact write). A graph validates once and correlates each edge independently without implying cross-edge causality.

Live event captures always write Event JSONL (or Chrome trace with --format chrome) plus <artifact>.manifest.json (schema 1.0) recording target identity, CLOCK_MONOTONIC window, wall_clock UTC anchors, all_gpu_activity, cuda_devices UUIDs, losses, and SHA-256. Offline measure --input verifies the manifest and re-correlates deterministically.