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
| Source | Selector |
|---|---|
| Native function | uprobe:<binary>:<symbol>:entry|return |
C++ signature with :: | uprobe:<binary>:symbol=<full-demangled-signature>:entry|return |
| Stripped / local offset | uprobe:<binary>:+0x<file-offset>:entry|return |
| Syscall | syscall:<name>:entry|exit |
| Kernel tracepoint | tracepoint:<category>:<name> (identity + timestamp only) |
| CPython GC | python:gc_start, python:gc_end (requires USDT markers in mapped Python/libpython) |
| CUDA Runtime / Driver API | cuda:runtime_api|driver_api:<name>:entry|exit |
| Any kernel launch API | cuda:launch_api:entry|exit (covers Runtime & Driver launches, including cuBLAS/Triton; uses 2 Agent filters) |
| GPU activity | cuda:kernel_start|kernel_end[:name~REGEX], cuda:memcpy_start|memcpy_end[:kind=HtoD|DtoH|DtoD|HtoH|PtoP], cuda:memset_start|memset_end |
| NVTX range | cuda: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) andsymbol_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 (
validateinspects mapped Python/libpythonELF metadata for bothpython:gc__startandpython:gc__doneUSDT markers). - CUDA launch:
cuda:launch_api:entry|exitmatches 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
| Policy | Pairs | Confidence |
|---|---|---|
exact | Same CUPTI correlation_id (API ↔ kernel/copy), activity start ↔ end, NVTX range ID, syscall entry ↔ exit per thread, CPython GC start ↔ end | exact |
stack-nested | Entry ↔ return of one host function per thread (LIFO) | high |
stream-order | Activity 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-after | First unused end at or after each start across unrelated sources | heuristic |
nearest | Nearest unused end by timestamp across unrelated sources | heuristic |
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_timemay be omitted (measurereads and verifies it around attach).- 1–8 endpoints and 1–8 edges; either every edge sets
samplesor the graph setsduration_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(withdetails.edge), while still writing the shared Event JSONL artifact so remaining edges can be re-correlated offline withmeasure --input.
Filter pushdown & overhead limits
- Agent hot-path filtering: kernel and NVTX
name~REGEXexpressions 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-eventsmuch faster; complex NVTX regexes fail validation. Escape regex metacharacters. If an aggregate group hasname_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-orderand--trigger-*record all GPU activity. On launch-bound workloads (tens of thousands of kernels/sec), keep--duration-msshort, bound hot paths with--samples, or size--max-eventsfrom an--aggregatecount. OnEVENT_RATE_TOO_HIGH, narrow the selector or shorten the window before raising--max-events.