Skip to main content

Selectors, Policies & Limits

Prefer selector hints emitted by xprobe (*_selector_hint in inventories, selector_hint in analyze_trace.py). Use xprobe validate when a hand-written selector or policy is uncertain.

Selector syntax​

SourceSelector
Native functionuprobe:<binary>:<symbol>:entry|return
C++ signature with ::uprobe:<binary>:symbol=<full-demangled-signature>:entry|return
Stripped / local offsetuprobe:<binary>:+0x<file-offset>:entry|return
Syscallsyscall:<name>:entry|exit
Kernel tracepointtracepoint:<category>:<name> (identity + timestamp only)
CPython GCpython:gc_start, python:gc_end (requires USDT markers in mapped Python/libpython)
CUDA Runtime / Driver APIcuda:runtime_api|driver_api:<name>:entry|exit
Any kernel launch APIcuda:launch_api:entry|exit (covers Runtime & Driver launches, including cuBLAS/Triton; uses 2 Agent filters)
GPU activitycuda:kernel_start|kernel_end[:name~REGEX], cuda:memcpy_start|memcpy_end[:kind=HtoD|DtoH|DtoD|HtoH|PtoP], cuda:memset_start|memset_end
NVTX rangecuda:nvtx_range_start|nvtx_range_end:name~REGEX

Notes:

  • Host C/C++: symbol= handles :: and punctuation in demangled C++ signatures, returning both the attachable mangled ELF name (symbol) and symbol_demangled. Does not resolve Python frames.
  • Syscalls & tracepoints: Linux x86_64 syscalls filter PID and syscall number in BPF before reading the six scalar entry registers and scalar return value (pointer arguments are never dereferenced). Unsupported names fail explicitly.
  • CPython GC: capability-based (validate inspects mapped Python/libpython ELF metadata for both python:gc__start and python:gc__done USDT markers).
  • CUDA launch: cuda:launch_api:entry|exit matches Runtime (cudaLaunchKernel, cudaLaunchKernelExC, cudaLaunchCooperativeKernel) and Driver (cuLaunchKernel, cuLaunchKernelEx, cuLaunchCooperativeKernel) launch APIs in one endpoint (a Runtime call and its inner Driver call count once as the Runtime call).

Resolving native symbols & offsets​

readlink -f "/proc/$PID/exe"
grep -F ' r-xp ' "/proc/$PID/maps"
readelf -Ws /path/to/object
nm -D --defined-only --demangle /path/to/object

Use file offsets (not runtime virtual addresses) for +0x<offset>. Re-validate C++ signatures, offsets, and generated kernel names across builds. JIT-generated CPU code without a file-backed ELF cannot be a uprobe target.


Match policies​

PolicyPairsConfidence
exactSame CUPTI correlation_id (API ↔ kernel/copy), activity start ↔ end, NVTX range ID, syscall entry ↔ exit per thread, CPython GC start ↔ endexact
stack-nestedEntry ↔ return of one host function per thread (LIFO)high
stream-orderActivity end ↔ next kernel/copy/memset start on the same device/context/stream (records all GPU activity; uses 6 of 8 Agent filters; warns STREAM_ORDER_CAPTURES_ALL_ACTIVITY; overlapping ends, tied successors, or truncated names mark ambiguous)high
first-afterFirst unused end at or after each start across unrelated sourcesheuristic
nearestNearest unused end by timestamp across unrelated sourcesheuristic

validate returns policy_recommendation with compatible alternatives; measure never overrides --match silently.


JSON specs & measurement graphs​

Single-edge repeatable spec (schema_version: "2.0"):

{
"schema_version": "2.0",
"name": "kernel_duration",
"target": {
"pid": 1234,
"process_start_time": 987654
},
"start_selector": "cuda:kernel_start:name~^vector_add$",
"end_selector": "cuda:kernel_end:name~^vector_add$",
"match_policy": "exact",
"samples": 100,
"duration_ms": null,
"timeout_ms": 30000,
"max_events": 1000
}

Measurement graph (schema_version: "3.0", captures 1–8 edges over 1–8 named endpoints in one capture):

{
"schema_version": "3.0",
"name": "request_path",
"target": {
"pid": 1234,
"process_start_time": 987654
},
"endpoints": {
"request": "uprobe:/srv/app/server:request_begin:entry",
"launch_exit": "cuda:launch_api:exit",
"kernel_start": "cuda:kernel_start:name~^vector_add",
"kernel_end": "cuda:kernel_end:name~^vector_add"
},
"edges": [
{"name": "request_to_launch", "from": "request", "to": "launch_exit", "match_policy": "first_after", "samples": 100},
{"name": "launch_to_kernel", "from": "launch_exit", "to": "kernel_start", "match_policy": "exact", "samples": 100},
{"name": "kernel_duration", "from": "kernel_start", "to": "kernel_end", "match_policy": "exact", "samples": 100}
],
"duration_ms": null,
"timeout_ms": 30000,
"max_events": 4000
}

Graph rules:

  • target.process_start_time may be omitted (measure reads and verifies it around attach).
  • 1–8 endpoints and 1–8 edges; either every edge sets samples or the graph sets duration_ms.
  • Endpoint slot limits: uprobe endpoints are unlimited; CUDA endpoints share 8 CUPTI Agent filters; syscall, tracepoint, and USDT endpoints share 2 Linux collector slots.
  • Any failing edge fails measure (with details.edge), while still writing the shared Event JSONL artifact so remaining edges can be re-correlated offline with measure --input.

Filter pushdown & overhead limits​

  • Agent hot-path filtering: kernel and NVTX name~REGEX expressions run inside the CUPTI Agent only when they reduce to a literal exact, prefix (^foo.*), suffix (.*foo$), or contains (.*foo.*) shorter than 128 bytes. Complex kernel regexes filter in the CLI after a broader capture and hit --max-events much faster; complex NVTX regexes fail validation. Escape regex metacharacters. If an aggregate group has name_complete: false, keep its truncated prefix without $.
  • Uprobe cost: uprobes trap into the kernel on every call (costlier on VMs/WSL2). Avoid uprobes on functions called tens of thousands of times per second; measure a coarser caller or use --cpu-sample / --syscall-aggregate.
  • High-rate GPU workloads: stream-order and --trigger-* record all GPU activity. On launch-bound workloads (tens of thousands of kernels/sec), keep --duration-ms short, bound hot paths with --samples, or size --max-events from an --aggregate count. On EVENT_RATE_TOO_HIGH, narrow the selector or shorten the window before raising --max-events.