From a83e4a39a7c00ba18ac12ae58fe527ad174e8bbe Mon Sep 17 00:00:00 2001 From: itdevwu Date: Sun, 29 Nov 2026 04:57:30 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=F0=9F=90=9B=20fix:=20check=20out=20before?= =?UTF-8?q?=20downloading=20the=20wheel=20in=20the=20PyPI=20job?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit actions/checkout cleans the workspace, so running it after the download removed dist/ and the SHA-256 check against the built wheel failed in the v0.7.0 release, after the publish had succeeded. --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6505220..f5cc723 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -157,12 +157,13 @@ jobs: permissions: id-token: write steps: + # Check out first: checkout cleans the workspace, including dist/. + - uses: actions/checkout@v6 - uses: actions/download-artifact@v8 with: name: xprobe-wheel path: dist - uses: pypa/gh-action-pypi-publish@release/v1 - - uses: actions/checkout@v6 - uses: actions/setup-python@v6 with: python-version: "3.12" From bb75cd33c6c3da7ec85c8e5b46483790b06cd122 Mon Sep 17 00:00:00 2001 From: itdevwu Date: Sun, 29 Nov 2026 04:57:30 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=91=B7=20ci:=20lint=20commit=20messag?= =?UTF-8?q?es=20on=20branches=20and=20pull=20requests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 17 +++++++++++++++++ docs/development.md | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 875505a..753f1eb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,23 @@ permissions: contents: read jobs: + commit-messages: + # Commits not on master yet: a pull request's own commits, or a branch's. + if: github.event_name == 'pull_request' || (startsWith(github.ref, 'refs/heads/') && github.ref != 'refs/heads/master') + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + - uses: actions/setup-python@v6 + with: + python-version: "3.12" + - run: python -m pip install gitlint-core==0.19.1 + - name: Lint commit messages + env: + RANGE: ${{ github.event_name == 'pull_request' && format('{0}..{1}', github.event.pull_request.base.sha, github.event.pull_request.head.sha) || 'origin/master..HEAD' }} + run: gitlint --commits "$RANGE" + build-and-test: runs-on: ubuntu-24.04 timeout-minutes: 30 diff --git a/docs/development.md b/docs/development.md index 0028914..7472324 100644 --- a/docs/development.md +++ b/docs/development.md @@ -22,7 +22,7 @@ Run `just --list` for the complete list. Key suites: | Recipe | What it tests | Notes | | --- | --- | --- | | `just test` | Rust unit/integration tests, CTest, CLI/Skill checks, `analyze_trace.py` fixtures | Offline, no GPU | -| `just lint-commits` | Commit titles fit in 72 characters and follow emoji conventional commits; bodies wrap at 80 | Checks `origin/master..HEAD`; `gitlint install-hook` runs it on each commit | +| `just lint-commits` | Commit titles fit in 72 characters and follow emoji conventional commits; bodies wrap at 80 | Checks `origin/master..HEAD`; CI runs it on branches and pull requests, and `gitlint install-hook` runs it on each commit | | `just test-agent-contract` | Public CLI shape, schemas, Skill links/flags/fields, analyzer fixtures | Run after CLI/schema/docs/Skill edits | | `just test-skill-install` | Real `npx skills` copy into isolated Codex, Claude Code, and Cursor homes | Needs Node.js | | `just test-install` | Archive install/uninstall, glibc 2.34 check, wheel/SBOM checks | Offline | From b34febf1e956f312f6ab51a719ac131ddf871c2b Mon Sep 17 00:00:00 2001 From: itdevwu Date: Sun, 29 Nov 2026 06:01:31 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=F0=9F=93=9D=20docs:=20rewrite=20the=20CLI?= =?UTF-8?q?=20reference=20for=20reading?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename docs/cli-contract.md to docs/cli-reference.md and restructure it without changing what it says: short sentences, one table per list of options, and a section per measure mode (latency, inventories, triage, triggers, the CUDA Agent, artifacts). Every flag, field, error code, and schema name from the old page is still there. --- README.md | 2 +- docs/cli-contract.md | 234 -------------------------------- docs/cli-reference.md | 309 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 310 insertions(+), 235 deletions(-) delete mode 100644 docs/cli-contract.md create mode 100644 docs/cli-reference.md diff --git a/README.md b/README.md index 7f76f01..49e118a 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ Because concurrent captures on one host share `CLOCK_MONOTONIC`, you can also jo ## ๐Ÿ“š Documentation - [Installation](docs/installation.md) -- [CLI contract](docs/cli-contract.md) +- [CLI reference](docs/cli-reference.md) - [Agent integration](docs/agent-integration.md) - [Architecture](docs/architecture.md) - [CUPTI agent and injection](docs/cupti-agent.md) diff --git a/docs/cli-contract.md b/docs/cli-contract.md deleted file mode 100644 index 1b09327..0000000 --- a/docs/cli-contract.md +++ /dev/null @@ -1,234 +0,0 @@ -# CLI reference - -xprobe exposes four public commands: `doctor`, `discover`, `validate`, and `measure`. - -## Common behavior - -- When stdout is not a terminal, every command writes one versioned JSON document to stdout; on a terminal it prints a human-readable report. `--json` forces JSON and `--human` forces text (mutually exclusive). -- `--non-interactive` and `--no-color` are accepted for scripting compatibility (xprobe never prompts or colors output). Diagnostics and injection warnings go to stderr. -- Schema versions: - - **`3.0`**: measurement, measurement-graph (spec, validate, result), GPU `--aggregate`, `--python-sample`, `--triage`, and `--trigger-*` results. - - **`2.0`**: `doctor`, `discover`, single-edge `validate`/`MeasurementSpec`, `--cpu-sample`, `--syscall-aggregate`, errors, and Event JSONL lines. - - **`1.0`**: capture manifests (`.manifest.json`). - - Unknown JSON fields and unsupported versions fail deserialization. - -| Exit code | Meaning | -| --- | --- | -| `0` | Command succeeded and printed a result | -| `1` | Validation, collection, decode, export, cleanup, or internal error | -| `2` | Invalid CLI syntax (Clap) | -| `3` | Target missing, exited, or reused | -| `4` | Permission denied for inspection, eBPF, or ptrace | - -Runtime errors conform to `schemas/error.schema.json` and carry a stable `code`, `message`, `recoverable`, `details`, and `hints`. - -## `doctor` - -```bash -xprobe doctor -``` - -Reports kernel/OS identity, BTF, BPF/perf permissions, lockdown, ptrace policy, NVIDIA driver, CUDA toolkit/driver, CUPTI libraries (each supported installed major and resolved path), namespaces, and capability booleans. `ok: true` means diagnostics completed, not that every collector is available. - -Privilege checks read `CapEff` (effective capability set), not UID: root in a container without `CAP_BPF` and `CAP_PERFMON` (or `CAP_SYS_ADMIN`) reports eBPF restricted, and live injection needs `CAP_SYS_PTRACE` unless `ptrace_scope` allows same-user tracing. - -## `discover` - -```bash -xprobe discover --pid 4242 --limit 200 -``` - -Queries NVML for active CUDA compute processes under process-tree root `--pid` without attaching, returning confirmed CUDA context holders (PID, procfs start time, parent PID, executable, command line, GPU UUIDs). `--limit` must be positive; `total_candidates` and `truncated` report output bounds. `discover` does not pick a worker or cover non-CUDA CPU/Python processes. - -Because NVML lists processes across all containers sharing a GPU, PIDs invisible in the caller's PID namespace (or exited during inspection) emit `NVML_PROCESS_UNAVAILABLE` with `nvml_pids` instead of failing. When none are visible, `NVML_PID_NAMESPACE_MISMATCH` notes that NVML returned host PIDs โ€” inside a container, pass the namespace-local PID directly to `validate`/`measure`. A failed NVML query or missing root PID returns an error. - -## Selectors - -Selectors are validated before any attachment: - -```text -uprobe:::entry -uprobe:::return -uprobe::symbol=:entry -uprobe::symbol=:return -uprobe::+0x:entry -uprobe::+0x:return -syscall::entry -syscall::exit -tracepoint:: -python:gc_start -python:gc_end -cuda:runtime_api::entry|exit -cuda:driver_api::entry|exit -cuda:launch_api:entry|exit -cuda:kernel_start|kernel_end[:name~REGEX] -cuda:memcpy_start|memcpy_end[:kind=HtoD|DtoH|DtoD|HtoH|PtoP] -cuda:memset_start|memset_end -cuda:nvtx_range_start|nvtx_range_end:name~REGEX -``` - -- **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). Tracepoints record identity and timestamp only. 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). Records identity, timestamp, binary, provider, and marker name only. -- **CUDA launch**: `cuda:launch_api:entry|exit` matches Runtime (`cudaLaunchKernel`, `cudaLaunchKernelExC`, `cudaLaunchCooperativeKernel`) and Driver (`cuLaunchKernel`, `cuLaunchKernelEx`, `cuLaunchCooperativeKernel`) launch APIs in one endpoint (covering cuBLAS, Triton, and Driver callers; a Runtime call and its inner Driver call count once as the Runtime call; uses 2 of 8 Agent filters). -- **NVTX & kernel regex**: NVTX `name~REGEX` must reduce to one nonempty exact, prefix, suffix, or contains literal shorter than 128 bytes. Kernel regexes matching that rule filter in the CUPTI Agent hot path; more complex regexes filter in Rust after a broader capture. - -## `validate` - -```bash -xprobe validate --pid 4242 \ - --from 'cuda:launch_api:exit' \ - --to 'cuda:kernel_start:name~flash.*' \ - --match exact -``` - -Read-only check of target identity, probe resolution, CUDA filters, correlation compatibility, and runtime requirements (`schemas/validate.schema.json`). - -- `--cpu-sample` checks target threads, perf-event access, and Python perf-map symbolization status. -- `--syscall-aggregate` checks the eBPF syscall aggregate path. -- `--spec graph.json` validates a measurement graph without `--pid` (`schemas/measurement-graph-validate.schema.json`, schema `3.0`), scoping issues to the graph, an endpoint, or an edge. -- `policy_recommendation` reports the strongest compatible policy, a machine-readable reason, and compatible alternatives without silently changing `--match`. -- `requirements.agent_activation` is `not_required`, `already_loaded`, `injection_required` (sets `target_mutation: true` and warns `TARGET_PROCESS_WILL_BE_MODIFIED`), or `startup_required` (NVTX selector without preloaded Agent โ€” returns `valid: false`). -- Conflicting or unsupported CUDA majors (outside 12 and 13) return `UNSUPPORTED_CUDA_VERSION`. - -### Correlation policies - -| Policy | Behavior | -| --- | --- | -| `exact` | CUPTI correlation ID, NVTX range kind/ID, same-thread syscall entry/exit, or same-thread CPython GC start/end | -| `stack-nested` | Same-thread LIFO host function entry/return | -| `stream-order` | GPU activity end to the next kernel, copy, or memset start on the same device/context/stream; records all GPU activity (6 of 8 Agent filters, warns `STREAM_ORDER_CAPTURES_ALL_ACTIVITY`); overlapping ends, tied successors, or truncated names that cannot decide the selector are marked ambiguous | -| `first-after`, `nearest` | Temporal matching across unrelated sources (always warned as heuristic) | - -## `measure` - -Exactly one source mode is used: `--pid`, one or more `--input`, or `--spec`. Live runs require `--samples` or `--duration-ms`; offline `--input` correlates all events when neither is set. Defaults: `--timeout-ms 30000`, `--max-events 100000`. - -### Common command forms - -```bash -# Live CUDA launch-to-kernel latency -xprobe measure --pid 4242 \ - --from 'cuda:launch_api:exit' --to 'cuda:kernel_start:name~flash.*' \ - --match exact --samples 100 --timeout-ms 30000 --events-out /tmp/xprobe-events.jsonl - -# Syscall duration -xprobe measure --pid 4242 \ - --from 'syscall:mmap:entry' --to 'syscall:mmap:exit' \ - --match exact --samples 100 --max-events 1000 - -# CPython GC duration -xprobe measure --pid 4242 \ - --from python:gc_start --to python:gc_end --match exact --samples 100 --max-events 1000 - -# NVTX range (target started with NVTX_INJECTION64_PATH) -xprobe measure --pid 4242 \ - --from 'cuda:nvtx_range_start:name~^forward$' \ - --to 'cuda:nvtx_range_end:name~^forward$' --match exact --samples 100 --max-events 1000 - -# CPU callchain hotspot inventory -xprobe measure --pid 4242 --cpu-sample --duration-ms 1000 \ - --frequency-hz 99 --max-samples 10000 --max-groups 256 --stack-depth 64 --max-threads 1024 - -# External CPython stacks & GIL holder -xprobe measure --pid 4242 --python-sample --duration-ms 2000 - -# Syscall totals inventory -xprobe measure --pid 4242 --syscall-aggregate --duration-ms 1000 \ - --max-groups 256 --max-inflight 1024 - -# GPU kernel/memcpy/memset totals inventory -xprobe measure --pid 4242 --from 'cuda:kernel_start' --to 'cuda:kernel_end' \ - --match exact --aggregate --duration-ms 1000 --max-groups 4096 - -# Same-window multi-source snapshot -xprobe measure --pid 4242 --triage --duration-ms 2000 - -# Offline re-correlation of saved captures -xprobe measure --input host.json --input cupti.bin \ - --from 'uprobe:/srv/app/server:request:entry' \ - --to 'cuda:kernel_start:name~flash.*' --match first-after --samples 100 - -# Versioned spec or measurement graph -xprobe measure --spec measurement.json -``` - -### Inventory & snapshot modes - -- **`--cpu-sample`** (live, `--duration-ms`, schema `2.0`): PID-scoped userspace callchain sampling (defaults: 99 Hz, 10,000 samples, 256 groups, depth 64, 1,024 threads). Resolves ELF symbols and `/tmp/perf-.map` Python frames independently, reporting `python_status`, uprobe selector hints, lost samples, and truncation. -- **`--python-sample`** (live, `--duration-ms`, schema `3.0`): reads CPython 3.9โ€“3.14 memory via `process_vm_readv` without 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), verifying offsets against `_Py_DebugOffsets` on 3.13+ (unsupported/free-threaded builds return `UNSUPPORTED_PYTHON_VERSION`). Discards racing reads (`inconsistent_reads`), reports blocked threads' `/proc//task//syscall` native waits, and writes every timestamped sample (`CLOCK_MONOTONIC`) to a JSONL artifact (`schemas/python-sample-record.schema.json`). Frames report `first_line` (function start), not current line. -- **`--syscall-aggregate`** (live, `--duration-ms`, schema `2.0`): PID-filtered BPF maps (`--max-inflight`, `--max-groups`) emitting per-syscall count, errors, min/mean/max/total duration, and selector hints. No per-call event stream or pointer values. -- **`--aggregate`** (live, `--duration-ms`, schema `3.0`): Agent-side aggregation (`--max-groups`, default 4,096) for one matching kernel, memcpy, or memset start/end pair. Kernel regex must reduce to a hot-path literal filter; names truncated at 127 bytes set `name_complete: false` with a prefix hint. Memcpy groups split by `src_memory` and `dst_memory` (`pageable`, `pinned`, `device`, `managed`, etc.). -- **`--triage`** (live, `--duration-ms`, schema `3.0`): concurrently collects procfs thread times, cgroup CPU throttling, CPU samples, external Python samples (when CPython), syscall aggregate, NVML device health, and CUDA kernel aggregate (may inject CUPTI). Writes full inventories to per-source artifacts, keeps top 5 entries inline, and attaches optional rule-based `findings` and `not_covered` notes. Unavailable or saturated sources become `unavailable` with `TRIAGE_SOURCE_UNAVAILABLE` rather than failing the whole run. - -Inventory modes (`--cpu-sample`, `--syscall-aggregate`, `--aggregate`) do not write Event JSONL and cannot be passed to `--input` or `--events-out`. - -### Live capture & CUDA Agent behavior - -- Host endpoints attach all eBPF links before arming. Duration captures that hit `--max-events` fail with `EVENT_RATE_TOO_HIGH`. -- CUDA endpoints auto-select `--agent`, `XPROBE_CUPTI_AGENT_PATH`, `../lib/xprobe/cuda12|cuda13`, or the matching build path. Live injection requires Linux x86_64, a shared mount namespace, and ptrace permission, emits a stderr warning and `CUPTI_AGENT_INJECTED`, disables CUPTI on stop, and removes its private socket while leaving the `.so` mapped. -- NVTX thread ranges track `(tid, push_level)`; process ranges track `range_id` across threads (`start_tid`). Supports ASCII `PushA`/`StartA` and `Ex` forms (no wide/registered strings or CUPTI Range Profiling). - -### Offline `--input` & capture manifests - -- Accepts CUPTI ABI binary, host-capture JSON, or Event JSONL. Repeated `--input` files are merged after rejecting mixed targets (same PID with different start times) and duplicate event content. -- Live captures always write the full capture with mode `0600` (`--events-out PATH` or a private mode-`0700` temp directory), defaulting to JSONL (`--format chrome` writes Chrome Trace Event Format). -- Beside every Event JSONL, xprobe writes `.manifest.json` (`schemas/capture-manifest.schema.json`, schema `1.0`) containing target identity, `CLOCK_MONOTONIC` window, selectors, `all_gpu_activity`, `peer_copies`, losses, `cuda_devices` UUIDs, `wall_clock` UTC start/end anchors (each bracketed by two monotonic reads with `uncertainty_ns`), size, and SHA-256. -- Offline `--input` verifies the manifest's size/SHA-256 and restores recorded losses and coverage. Without manifests, coverage is `unverified` (or `unverified_merge`), and `stream-order` falls back to heuristic with a caution. -- Even when correlation, clock, drop, or capacity errors occur after collection, the artifact is still written and its path is included in the JSON error (`TRACE_EXPORT_FAILED` preserves the original error code in `details`). - -### Results (`schemas/measurement-result.schema.json`, schema `3.0`) - -Includes `status`, `measurement.latency_ns` & `measurement.samples`, `quality` (`good` or `caution` with coded issues), `correlation`, `clock`, `collection` (completeness, CUPTI utilization/drops, `cuda_devices`, `wall_clock`), `evidence` (rank exemplars min/p50/p90/p99/max, artifact path, and with `--evidence full` all pairs), and `warnings`. - -Error codes include `NO_MATCHED_SAMPLES`, `CLOCK_ALIGNMENT_FAILED`, `EVENT_RATE_TOO_HIGH`, `EVENTS_DROPPED`, `TRIGGER_NOT_OBSERVED`, `TARGET_EXITED`, `TARGET_REUSED`, and `CLEANUP_FAILED`. Structured `details` and `hints` carry machine-readable follow-up data. - -### Triggered capture (`--trigger-*`) - -```bash -xprobe measure --pid 4242 --trigger-idle-ms 10 --pre-ms 50 --post-ms 50 \ - --timeout-ms 300000 --max-events 400000 --events-out /tmp/spikes -``` - -Waits for rare slow spans using an in-Agent ring of `--max-events` records and writes `window-N.events.jsonl` plus manifest into `--events-out` (directory) for `--pre-ms` before to `--post-ms` after each firing span, up to `--windows` non-overlapping windows (default 1): - -- `--trigger-idle-ms`: device runs no kernel, copy, or memset of the target on any stream. -- `--trigger-gap-ms`: gap between an activity end and the next kernel, copy, or memset on the same stream. -- `--trigger-duration-ms`: single kernel, copy, or memset duration. -- `--trigger-latency-ms`: `--from`/`--to` CUDA edge latency under `--match`. - -Idle, gap, duration, and `stream-order` latency triggers record all GPU activity. A window that overlaps overwritten or dropped records is not written and counts in `lost_windows`. If a record read later shows activity inside an idle or gap window, the window is dropped and counts in `revoked_windows`, and capture keeps waiting for another span until the timeout. Latency and duration windows are written as they fired. `observed` counts every span seen, including those whose records the CLI no longer holds. If no window is written, timeout returns `TRIGGER_NOT_OBSERVED` with `longest_ns` in `details`; if every window lost records, it returns `EVENTS_DROPPED`. Emits `schemas/trigger-result.schema.json` (schema `3.0`). - -## Measurement graphs - -Measures 1โ€“8 edges over 1โ€“8 named endpoints from one capture (`schemas/measurement-graph-spec.schema.json`, schema `3.0`): - -```json -{ - "schema_version": "3.0", - "name": "request_path", - "target": {"pid": 4242, "process_start_time": 123456}, - "endpoints": { - "request": "uprobe:/srv/app/server:handle_request:entry", - "launch_exit": "cuda:launch_api:exit", - "kernel_start": "cuda:kernel_start:name~^flash", - "kernel_end": "cuda:kernel_end:name~^flash" - }, - "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": 20000 -} -``` - -- `target.process_start_time` is optional (`measure` reads and verifies it around attach). -- Either every edge sets `samples` or the graph sets `duration_ms`; `max_events` caps the capture. -- Collectors attach once per unique endpoint: uprobes are unlimited; CUDA endpoints share 8 Agent filters; syscall, tracepoint, and USDT endpoints share 2 Linux slots. -- Each edge correlates independently (`schemas/measurement-graph-result.schema.json`, schema `3.0`). Any failing edge fails the command (with `details.edge`) while still writing the shared Event JSONL artifact for offline `measure --input`. diff --git a/docs/cli-reference.md b/docs/cli-reference.md new file mode 100644 index 0000000..fd0ee28 --- /dev/null +++ b/docs/cli-reference.md @@ -0,0 +1,309 @@ +# CLI reference + +xprobe has four public commands: + +| Command | What it does | +| --- | --- | +| `doctor` | Reports what this host and container allow xprobe to collect. | +| `discover` | Lists CUDA processes under a process tree without attaching. | +| `validate` | Checks a target and selectors read-only, before anything attaches. | +| `measure` | Collects, correlates, and writes results and artifacts. | + +## Output + +When stdout is not a terminal, every command writes one versioned JSON document to stdout. On a terminal it prints a readable report. `--json` and `--human` force one or the other and cannot be combined. + +xprobe never prompts and never colors output; `--non-interactive` and `--no-color` are accepted for scripts that pass them. Diagnostics and injection warnings go to stderr. + +| Schema version | Documents | +| --- | --- | +| **`3.0`** | Measurement and measurement-graph (spec, validate, result), GPU `--aggregate`, `--python-sample`, `--triage`, and `--trigger-*` results | +| **`2.0`** | `doctor`, `discover`, single-edge `validate` and `MeasurementSpec`, `--cpu-sample`, `--syscall-aggregate`, errors, and Event JSONL lines | +| **`1.0`** | Capture manifests (`.manifest.json`) | + +Unknown JSON fields and unsupported versions fail deserialization. + +| Exit code | Meaning | +| --- | --- | +| `0` | Command succeeded and printed a result | +| `1` | Validation, collection, decode, export, cleanup, or internal error | +| `2` | Invalid CLI syntax (Clap) | +| `3` | Target missing, exited, or reused | +| `4` | Permission denied for inspection, eBPF, or ptrace | + +Runtime errors follow `schemas/error.schema.json`: a stable `code`, a `message`, `recoverable`, and machine-readable `details` and `hints`. + +## `doctor` + +```bash +xprobe doctor +``` + +Reports kernel and OS identity, BTF, BPF and perf permissions, lockdown, ptrace policy, the NVIDIA driver, the CUDA toolkit and driver, each installed CUPTI major with its path, namespaces, and capability booleans. `ok: true` means the diagnostics ran, not that every collector is available. + +Privilege checks read `CapEff` (the effective capability set), not the UID. Root in a container without `CAP_BPF` and `CAP_PERFMON` (or `CAP_SYS_ADMIN`) reports eBPF as restricted. Live injection needs `CAP_SYS_PTRACE` unless `ptrace_scope` allows tracing a process of the same user. + +## `discover` + +```bash +xprobe discover --pid 4242 --limit 200 +``` + +Asks NVML for active CUDA compute processes under the process tree rooted at `--pid`, without attaching. Each result is a confirmed CUDA context holder with its PID, procfs start time, parent PID, executable, command line, and GPU UUIDs. `--limit` must be positive; `total_candidates` and `truncated` show whether the list was cut. `discover` does not choose a worker and does not list CPU-only or Python-only processes. + +NVML lists processes from every container that shares a GPU: + +- PIDs this PID namespace cannot see, or that exited during inspection, are reported in `nvml_pids` with `NVML_PROCESS_UNAVAILABLE` instead of failing the command. +- When none are visible, `NVML_PID_NAMESPACE_MISMATCH` notes that NVML returned host PIDs. Inside a container, pass the namespace-local PID to `validate` and `measure` directly. +- A failed NVML query or a missing root PID is an error. + +## Selectors + +Selectors are validated before anything attaches: + +```text +uprobe:::entry +uprobe:::return +uprobe::symbol=:entry +uprobe::symbol=:return +uprobe::+0x:entry +uprobe::+0x:return +syscall::entry +syscall::exit +tracepoint:: +python:gc_start +python:gc_end +cuda:runtime_api::entry|exit +cuda:driver_api::entry|exit +cuda:launch_api:entry|exit +cuda:kernel_start|kernel_end[:name~REGEX] +cuda:memcpy_start|memcpy_end[:kind=HtoD|DtoH|DtoD|HtoH|PtoP] +cuda:memset_start|memset_end +cuda:nvtx_range_start|nvtx_range_end:name~REGEX +``` + +- **Host C/C++**: `symbol=` takes a full demangled C++ signature, including `::` and punctuation. Validation returns the mangled ELF name to attach (`symbol`) and `symbol_demangled`. Uprobes do not resolve Python frames. +- **Syscalls**: Linux x86_64 only. BPF filters on PID and syscall number before it reads the six scalar entry registers or the scalar return value. Pointer arguments are never read. +- **Tracepoints** record identity and timestamp only. Unsupported names fail explicitly. +- **CPython GC**: chosen by what the target maps, not its process name. `validate` checks the Python or `libpython` ELF for both the `python:gc__start` and `python:gc__done` USDT markers. Records hold identity, timestamp, binary, provider, and marker name only. +- **CUDA launch**: `cuda:launch_api:entry|exit` matches the Runtime launch APIs (`cudaLaunchKernel`, `cudaLaunchKernelExC`, `cudaLaunchCooperativeKernel`) and the Driver ones (`cuLaunchKernel`, `cuLaunchKernelEx`, `cuLaunchCooperativeKernel`), so it covers cuBLAS, Triton, and Driver callers. A Runtime call and the Driver call inside it count once, as the Runtime call. It uses 2 of the 8 Agent filters. +- **NVTX and kernel names**: an NVTX `name~REGEX` must reduce to one nonempty exact, prefix, suffix, or contains literal shorter than 128 bytes. A kernel regex that reduces the same way is filtered in the CUPTI Agent's hot path; a more complex one is filtered in Rust after a broader capture. + +## `validate` + +```bash +xprobe validate --pid 4242 \ + --from 'cuda:launch_api:exit' \ + --to 'cuda:kernel_start:name~flash.*' \ + --match exact +``` + +A read-only check of target identity, probe resolution, CUDA filters, correlation, and runtime requirements (`schemas/validate.schema.json`). + +- `--cpu-sample` checks target threads, perf-event access, and whether Python perf-map symbols are available. +- `--syscall-aggregate` checks the eBPF syscall aggregate path. +- `--spec graph.json` validates a measurement graph without `--pid` (`schemas/measurement-graph-validate.schema.json`, schema `3.0`). Each issue is scoped to the graph, an endpoint, or an edge. +- `policy_recommendation` gives the strongest compatible policy, a machine-readable reason, and the compatible alternatives. It never changes `--match` for you. +- `requirements.agent_activation` is one of: + - `not_required` + - `already_loaded` + - `injection_required`: `measure` will inject the Agent; sets `target_mutation: true` and warns `TARGET_PROCESS_WILL_BE_MODIFIED`. + - `startup_required`: an NVTX selector needs the Agent loaded at startup; `valid: false`. +- A CUDA major other than 12 or 13, or conflicting majors, returns `UNSUPPORTED_CUDA_VERSION`. + +## Correlation policies + +| Policy | Pairs | +| --- | --- | +| `exact` | By CUPTI correlation ID, NVTX range kind and ID, same-thread syscall entry and exit, or same-thread CPython GC start and end | +| `stack-nested` | Same-thread host function entry and return, innermost first | +| `stream-order` | A GPU activity end with the next kernel, copy, or memset start on the same device, context, and stream | +| `first-after`, `nearest` | By time across unrelated sources; always warned as heuristic | + +`stream-order` records all GPU activity, uses 6 of the 8 Agent filters, and warns `STREAM_ORDER_CAPTURES_ALL_ACTIVITY`. Overlapping ends, tied successors, and names too truncated to decide the selector are marked ambiguous. + +## `measure` + +A run reads from exactly one source: `--pid` (live), one or more `--input` files (offline), or `--spec`. Live runs need `--samples` or `--duration-ms`. Offline `--input` correlates every event when neither is set. Defaults: `--timeout-ms 30000`, `--max-events 100000`. + +### Examples + +```bash +# Live CUDA launch-to-kernel latency +xprobe measure --pid 4242 \ + --from 'cuda:launch_api:exit' --to 'cuda:kernel_start:name~flash.*' \ + --match exact --samples 100 --timeout-ms 30000 --events-out /tmp/xprobe-events.jsonl + +# Syscall duration +xprobe measure --pid 4242 \ + --from 'syscall:mmap:entry' --to 'syscall:mmap:exit' \ + --match exact --samples 100 --max-events 1000 + +# CPython GC duration +xprobe measure --pid 4242 \ + --from python:gc_start --to python:gc_end --match exact --samples 100 --max-events 1000 + +# NVTX range (target started with NVTX_INJECTION64_PATH) +xprobe measure --pid 4242 \ + --from 'cuda:nvtx_range_start:name~^forward$' \ + --to 'cuda:nvtx_range_end:name~^forward$' --match exact --samples 100 --max-events 1000 + +# CPU callchain hotspot inventory +xprobe measure --pid 4242 --cpu-sample --duration-ms 1000 \ + --frequency-hz 99 --max-samples 10000 --max-groups 256 --stack-depth 64 --max-threads 1024 + +# External CPython stacks & GIL holder +xprobe measure --pid 4242 --python-sample --duration-ms 2000 + +# Syscall totals inventory +xprobe measure --pid 4242 --syscall-aggregate --duration-ms 1000 \ + --max-groups 256 --max-inflight 1024 + +# GPU kernel/memcpy/memset totals inventory +xprobe measure --pid 4242 --from 'cuda:kernel_start' --to 'cuda:kernel_end' \ + --match exact --aggregate --duration-ms 1000 --max-groups 4096 + +# Same-window multi-source snapshot +xprobe measure --pid 4242 --triage --duration-ms 2000 + +# Offline re-correlation of saved captures +xprobe measure --input host.json --input cupti.bin \ + --from 'uprobe:/srv/app/server:request:entry' \ + --to 'cuda:kernel_start:name~flash.*' --match first-after --samples 100 + +# Versioned spec or measurement graph +xprobe measure --spec measurement.json +``` + +### Latency results + +`schemas/measurement-result.schema.json`, schema `3.0`: + +- `status` +- `measurement.latency_ns` and `measurement.samples` +- `quality`: `good`, or `caution` with coded issues +- `correlation` and `clock` +- `collection`: completeness, CUPTI utilization and drops, `cuda_devices`, `wall_clock` +- `evidence`: exemplars at min, p50, p90, p99, and max, the artifact path, and every pair with `--evidence full` +- `warnings` + +Error codes include `NO_MATCHED_SAMPLES`, `CLOCK_ALIGNMENT_FAILED`, `EVENT_RATE_TOO_HIGH`, `EVENTS_DROPPED`, `TRIGGER_NOT_OBSERVED`, `TARGET_EXITED`, `TARGET_REUSED`, and `CLEANUP_FAILED`. + +### Inventories + +Each inventory is a live mode that runs for `--duration-ms` and reports totals instead of pairs. + +| Mode | Collects | Schema | +| --- | --- | --- | +| `--cpu-sample` | PID-scoped userspace callchains from perf events | `2.0` | +| `--python-sample` | CPython stacks and the GIL holder, read from outside the process | `3.0` | +| `--syscall-aggregate` | Per-syscall counts and durations in BPF maps | `2.0` | +| `--aggregate` | Agent-side totals for one kernel, memcpy, or memset start/end pair | `3.0` | + +`--cpu-sample`, `--syscall-aggregate`, and `--aggregate` write no Event JSONL, so their output cannot be passed to `--input` or `--events-out`. + +**`--cpu-sample`** defaults to 99 Hz, 10,000 samples, 256 groups, depth 64, and 1,024 threads. It resolves ELF symbols and `/tmp/perf-.map` Python frames separately and reports `python_status`, uprobe selector hints, lost samples, and truncation. + +**`--python-sample`** reads CPython 3.9โ€“3.14 memory with `process_vm_readv`. It needs ptrace access but no perf events, eBPF, `-X perf`, or injection. + +- It samples the GIL holder at `--python-hz` (default 2000) and all threads at `--python-threads-hz` (default 100). +- On 3.13 and later it checks its offsets against `_Py_DebugOffsets`. Unsupported and free-threaded builds return `UNSUPPORTED_PYTHON_VERSION`. +- Reads that race with the interpreter are discarded and counted in `inconsistent_reads`. +- For blocked threads it reports native waits from `/proc//task//syscall`. +- Every sample is written with its `CLOCK_MONOTONIC` time to a JSONL artifact (`schemas/python-sample-record.schema.json`). +- Frames report `first_line`, the line where the function starts, not the current line. + +**`--syscall-aggregate`** filters by PID in BPF maps sized by `--max-inflight` and `--max-groups`. It reports each syscall's count, errors, min, mean, max, and total duration, with selector hints. It records no per-call events and no pointer values. + +**`--aggregate`** groups in the Agent, up to `--max-groups` (default 4,096). + +- The kernel regex must reduce to a literal the hot path can filter on. +- Names cut at 127 bytes set `name_complete: false` and give a prefix hint. +- Memcpy groups split by `src_memory` and `dst_memory` (`pageable`, `pinned`, `device`, `managed`, and others). + +### Triage + +`--triage` runs for `--duration-ms` and collects, at the same time: + +- procfs thread times and cgroup CPU throttling +- CPU samples, and external Python samples for a CPython target +- the syscall aggregate +- NVML device health +- the CUDA kernel aggregate, which may inject CUPTI + +Full inventories go to one artifact per source, and the top 5 entries of each are kept inline. Optional rule-based `findings` and `not_covered` notes are attached. A source that is unavailable or saturated is marked `unavailable` with `TRIAGE_SOURCE_UNAVAILABLE` instead of failing the run. Schema `3.0`. + +### Triggered capture + +```bash +xprobe measure --pid 4242 --trigger-idle-ms 10 --pre-ms 50 --post-ms 50 \ + --timeout-ms 300000 --max-events 400000 --events-out /tmp/spikes +``` + +Waits for a rare slow span. Records stay in a ring of `--max-events` inside the Agent. For each span that fires, xprobe writes `window-N.events.jsonl` and its manifest into the `--events-out` directory, covering `--pre-ms` before the span to `--post-ms` after it. It writes up to `--windows` windows (default 1), which never overlap. + +| Trigger | Fires when | +| --- | --- | +| `--trigger-idle-ms` | The device runs no kernel, copy, or memset of the target on any stream for this long | +| `--trigger-gap-ms` | The gap between an activity end and the next kernel, copy, or memset on the same stream reaches this | +| `--trigger-duration-ms` | One kernel, copy, or memset runs this long | +| `--trigger-latency-ms` | The `--from`/`--to` CUDA edge under `--match` reaches this | + +Idle, gap, duration, and `stream-order` latency triggers record all GPU activity. + +- A window that overlaps overwritten or dropped records is not written and counts in `lost_windows`. +- If a record read later shows activity inside an idle or gap window, that window is dropped and counts in `revoked_windows`. Capture keeps waiting for another span until the timeout. +- Latency and duration windows are written as they fired. +- `observed` counts every span seen, including those whose records the CLI no longer holds. +- If no window is written, the timeout returns `TRIGGER_NOT_OBSERVED` with `longest_ns` in `details`. If every window lost records, it returns `EVENTS_DROPPED`. + +Results follow `schemas/trigger-result.schema.json` (schema `3.0`). + +### Live capture and the CUDA Agent + +- Host endpoints attach every eBPF link before arming. A duration capture that reaches `--max-events` fails with `EVENT_RATE_TOO_HIGH`. +- CUDA endpoints find the Agent from `--agent`, then `XPROBE_CUPTI_AGENT_PATH`, then `../lib/xprobe/cuda12|cuda13`, then the matching build path. +- Live injection needs Linux x86_64, the same mount namespace as the target, and ptrace permission. It prints a warning to stderr and emits `CUPTI_AGENT_INJECTED`. On stop it disables CUPTI and removes its private socket; the `.so` stays mapped. +- NVTX thread ranges are tracked by `(tid, push_level)` and process ranges by `range_id` across threads (`start_tid`). ASCII `PushA`/`StartA` and the `Ex` forms are supported; wide and registered strings and CUPTI Range Profiling are not. + +### Artifacts and offline input + +- A live capture always writes the full capture with mode `0600`, to `--events-out PATH` or a private mode-`0700` temporary directory. The default format is JSONL; `--format chrome` writes Chrome Trace Event Format. +- Beside every Event JSONL, xprobe writes `.manifest.json` (`schemas/capture-manifest.schema.json`, schema `1.0`) with the target identity, the `CLOCK_MONOTONIC` window, selectors, `all_gpu_activity`, `peer_copies`, losses, `cuda_devices` UUIDs, `wall_clock` UTC start and end anchors (each between two monotonic reads, with `uncertainty_ns`), size, and SHA-256. +- If correlation, clock, drop, or capacity checks fail after collection, the artifact is still written and its path is in the JSON error. `TRACE_EXPORT_FAILED` keeps the original error code in `details`. +- `--input` accepts the CUPTI ABI binary, host-capture JSON, or Event JSONL. Several `--input` files are merged after rejecting mixed targets (one PID with different start times) and duplicate event content. +- Offline input checks each manifest's size and SHA-256 and restores the recorded losses and coverage. Without a manifest, coverage is `unverified` (or `unverified_merge` for merged files), and `stream-order` falls back to a heuristic with a caution. + +## Measurement graphs + +A graph measures 1โ€“8 edges over 1โ€“8 named endpoints from one capture (`schemas/measurement-graph-spec.schema.json`, schema `3.0`): + +```json +{ + "schema_version": "3.0", + "name": "request_path", + "target": {"pid": 4242, "process_start_time": 123456}, + "endpoints": { + "request": "uprobe:/srv/app/server:handle_request:entry", + "launch_exit": "cuda:launch_api:exit", + "kernel_start": "cuda:kernel_start:name~^flash", + "kernel_end": "cuda:kernel_end:name~^flash" + }, + "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": 20000 +} +``` + +- `target.process_start_time` is optional; `measure` reads it and checks it around attach. +- Either every edge sets `samples`, or the graph sets `duration_ms`. `max_events` caps the capture. +- Collectors attach once per unique endpoint. Uprobes have no limit; CUDA endpoints share the 8 Agent filters; syscall, tracepoint, and USDT endpoints share 2 Linux slots. +- Each edge correlates on its own (`schemas/measurement-graph-result.schema.json`, schema `3.0`). If any edge fails, the command fails with `details.edge`, and the shared Event JSONL is still written for offline `measure --input`. From 5011f3c3f1188313d76a745f3ddd1e0a06c9cd7c Mon Sep 17 00:00:00 2001 From: itdevwu Date: Sun, 29 Nov 2026 23:41:38 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=F0=9F=93=9D=20docs:=20link=20the=20full=20?= =?UTF-8?q?English=20and=20Chinese=20documentation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 49e118a..fddd0ef 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,8 @@ Because concurrent captures on one host share `CLOCK_MONOTONIC`, you can also jo ## ๐Ÿ“š Documentation +Full documentation: [English](https://docs.itdevwu.com/en/xprobe) ยท [ไธญๆ–‡](https://docs.itdevwu.com/xprobe) + - [Installation](docs/installation.md) - [CLI reference](docs/cli-reference.md) - [Agent integration](docs/agent-integration.md) From ff4338543553b62548b2ea318f7d5e6305adc8a6 Mon Sep 17 00:00:00 2001 From: itdevwu Date: Tue, 1 Dec 2026 22:43:17 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=F0=9F=8E=A8=20style:=20add=20overhead=20be?= =?UTF-8?q?nchmark=20SVGs=20to=20README=20and=20benchmarks=20doc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add `render_benchmarks` to `scripts/render-readme-art.py` to generate `docs/assets/xprobe-bench-{light,dark}.svg` in the same Maple Mono and Geist style as the hero art, plotting overhead relative to a 1.00x baseline across Python, native CPU/eBPF, and CUDA/CUPTI benchmarks. - Embed the light/dark benchmark SVGs in `README.md` (`Measured overhead`) and `docs/benchmarks.md` (`Sample measurements`). --- README.md | 11 +++ docs/assets/xprobe-bench-dark.svg | 7 ++ docs/assets/xprobe-bench-light.svg | 7 ++ docs/benchmarks.md | 7 ++ scripts/render-readme-art.py | 138 +++++++++++++++++++++++++++++ 5 files changed, 170 insertions(+) create mode 100644 docs/assets/xprobe-bench-dark.svg create mode 100644 docs/assets/xprobe-bench-light.svg diff --git a/README.md b/README.md index fddd0ef..1f40812 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,17 @@ skills/xprobe-perf-profiling/scripts/analyze_trace.py rank0.jsonl rank1.jsonl ra Because concurrent captures on one host share `CLOCK_MONOTONIC`, you can also join traces across different processes (for example, an API/scheduler process and its GPU workers) in a few lines of Python, or re-correlate saved Event JSONL offline with `xprobe measure --input`. +## ๐Ÿ“Š Measured overhead + +

+ + + Measured xprobe profiling overhead across Python external sampling, CPU sampling, uprobes, CUPTI, perf, and py-spy + +

+ +

2 s runs per case; lower is better (1.00x = zero overhead). See Benchmarks for full methodology, stress numbers, and reproducible recipes.

+ ## ๐Ÿ› ๏ธ Commands & runtime notes | Command | Purpose | diff --git a/docs/assets/xprobe-bench-dark.svg b/docs/assets/xprobe-bench-dark.svg new file mode 100644 index 0000000..2dcbd2a --- /dev/null +++ b/docs/assets/xprobe-bench-dark.svg @@ -0,0 +1,7 @@ +xprobe: measured profiling overhead benchmarksThroughput ratio without versus with profiling across Python external sampling, CPU sampling, uprobes, CUPTI, perf, and py-spy.xprobe ยท measured profiling overheadxprobe v0.7COLLECTOR & WORKLOADRATIO1.00x+5%+10%+15%+20%PYTHONxprobe --python-sample3.12 ยท 2,000 Hz ยท 39 ยตs0.984xxprobe --python-sample3.10 ยท 2,000 Hz ยท 68 ยตs0.991xxprobe GC USDT3.12 ยท GC lifecycles1.020xxprobe --cpu-sample3.12 -X perf ยท 199 Hz1.027xpy-spy record3.12 ยท 199 Hz ยท pauses1.184xNATIVE CPU & EBPFperf recordnative ยท 199 Hz1.009xxprobe --cpu-samplenative ยท 199 Hz1.011xxprobe uprobeentry+return ยท 1,300/s1.042xCUDA / CUPTIxprobe CUPTIpaced ยท 6,800 ev/s1.0005xxprobeperf / py-spyRatio = throughput without / with profiling (2 s runs ยท lower is better ยท <1.00x is noise) diff --git a/docs/assets/xprobe-bench-light.svg b/docs/assets/xprobe-bench-light.svg new file mode 100644 index 0000000..272669a --- /dev/null +++ b/docs/assets/xprobe-bench-light.svg @@ -0,0 +1,7 @@ +xprobe: measured profiling overhead benchmarksThroughput ratio without versus with profiling across Python external sampling, CPU sampling, uprobes, CUPTI, perf, and py-spy.xprobe ยท measured profiling overheadxprobe v0.7COLLECTOR & WORKLOADRATIO1.00x+5%+10%+15%+20%PYTHONxprobe --python-sample3.12 ยท 2,000 Hz ยท 39 ยตs0.984xxprobe --python-sample3.10 ยท 2,000 Hz ยท 68 ยตs0.991xxprobe GC USDT3.12 ยท GC lifecycles1.020xxprobe --cpu-sample3.12 -X perf ยท 199 Hz1.027xpy-spy record3.12 ยท 199 Hz ยท pauses1.184xNATIVE CPU & EBPFperf recordnative ยท 199 Hz1.009xxprobe --cpu-samplenative ยท 199 Hz1.011xxprobe uprobeentry+return ยท 1,300/s1.042xCUDA / CUPTIxprobe CUPTIpaced ยท 6,800 ev/s1.0005xxprobeperf / py-spyRatio = throughput without / with profiling (2 s runs ยท lower is better ยท <1.00x is noise) diff --git a/docs/benchmarks.md b/docs/benchmarks.md index 6a424e0..451a820 100644 --- a/docs/benchmarks.md +++ b/docs/benchmarks.md @@ -2,6 +2,13 @@ ## Sample measurements +

+ + + Measured xprobe profiling overhead across Python external sampling, CPU sampling, uprobes, CUPTI, perf, and py-spy + +

+ One run on WSL2 with an RTX 3060 Laptop GPU (xprobe 0.7), measured as the ratio of target throughput without vs. with profiling over 2 s per case (lower is better; `1.00` = zero overhead): | Collector | Workload | Throughput ratio | Event / sample rate | diff --git a/scripts/render-readme-art.py b/scripts/render-readme-art.py index 34e3519..a0e99cd 100755 --- a/scripts/render-readme-art.py +++ b/scripts/render-readme-art.py @@ -378,6 +378,143 @@ def social_card() -> str: ) +def render_benchmarks(theme_name: str) -> str: + """Render measured profiling overhead from docs/benchmarks.md.""" + t = THEMES[theme_name] + w, h = 960, 500 + x_base = 490.0 + px_per_unit = 1700.0 # 1% overhead = 17 px + + def x_of(ratio: float) -> float: + return x_base + (ratio - 1.0) * px_per_unit + + sections = [ + ( + "PYTHON", + t["purple"], + 108, + [ + ("xprobe --python-sample", "3.12 ยท 2,000 Hz ยท 39 ยตs", 0.984, "0.984x", t["purple"], "solid"), + ("xprobe --python-sample", "3.10 ยท 2,000 Hz ยท 68 ยตs", 0.991, "0.991x", t["purple"], "solid"), + ("xprobe GC USDT", "3.12 ยท GC lifecycles", 1.020, "1.020x", t["purple"], "solid"), + ("xprobe --cpu-sample", "3.12 -X perf ยท 199 Hz", 1.027, "1.027x", t["purple"], "solid"), + ("py-spy record", "3.12 ยท 199 Hz ยท pauses", 1.184, "1.184x", t["muted"], "ref"), + ], + ), + ( + "NATIVE CPU & EBPF", + t["blue"], + 286, + [ + ("perf record", "native ยท 199 Hz", 1.009, "1.009x", t["muted"], "ref"), + ("xprobe --cpu-sample", "native ยท 199 Hz", 1.011, "1.011x", t["blue"], "solid"), + ("xprobe uprobe", "entry+return ยท 1,300/s", 1.042, "1.042x", t["blue"], "solid"), + ], + ), + ( + "CUDA / CUPTI", + t["green"], + 404, + [ + ("xprobe CUPTI", "paced ยท 6,800 ev/s", 1.0005, "1.0005x", t["green"], "solid"), + ], + ), + ] + + parts = [ + f'', + f'', + '', + '', + '', + text(92, 39, "xprobe ยท measured profiling overhead", 13, t["muted"], cls="sans", weight="500"), + pill(816, 24, 108, 22, "xprobe v0.7", t["blue"], t["blue_soft"], stroke=t["border"], size=10.5), + f'', + # Main chart card + f'', + text(50, 88, "COLLECTOR & WORKLOAD", 10.5, t["muted"], cls="sans", weight="700"), + text(910, 88, "RATIO", 10.5, t["muted"], cls="sans", weight="700", anchor="end"), + ] + + # Axis ticks & vertical gridlines + for ratio, label in ((1.00, "1.00x"), (1.05, "+5%"), (1.10, "+10%"), (1.15, "+15%"), (1.20, "+20%")): + gx = x_of(ratio) + is_base = ratio == 1.00 + stroke = t["muted"] if is_base else t["grid"] + dash = ' stroke-dasharray="4 3"' if is_base else "" + sw = "1.4" if is_base else "1" + parts.append( + text(gx, 88, label, 10.5, t["text"] if is_base else t["muted"], weight="700" if is_base else "400", anchor="middle") + + f'' + ) + + # Section dividers + for dy in (268, 386): + parts.append(f'') + + # Rows + for heading, heading_color, hy, rows in sections: + parts.append(text(50, hy, heading, 10.5, heading_color, cls="sans", weight="700")) + for idx, (name, meta, ratio, value_label, color, kind) in enumerate(rows): + ry = hy + 20 + idx * 30 + bar_y = ry - 9 + bar_h = 12 + parts.append( + text(50, ry, name, 11.5, t["muted"] if kind == "ref" else t["text"], weight="600" if kind != "ref" else "400") + + text(438, ry, meta, 10.5, t["muted"], anchor="end") + + f'' + ) + if ratio >= 1.0: + bx = x_base + bw = max(4.0, (ratio - 1.0) * px_per_unit) + else: + bw = max(4.0, (1.0 - ratio) * px_per_unit) + bx = x_base - bw + if kind == "ref": + parts.append( + f'' + ) + else: + parts.append( + f'' + ) + val_color = t["muted"] if kind == "ref" else t["text"] + parts.append(text(910, ry, value_label, 11.5, val_color, weight="700" if kind != "ref" else "600", anchor="end")) + + # Footer legend + note + fy = 469 + parts.extend( + [ + f'', + text(52, fy, "xprobe", 10.5, t["muted"], cls="sans"), + f'', + text(124, fy, "perf / py-spy", 10.5, t["muted"], cls="sans"), + text( + 924, + fy, + "Ratio = throughput without / with profiling (2 s runs ยท lower is better ยท <1.00x is noise)", + 10.5, + t["muted"], + cls="sans", + anchor="end", + ), + ] + ) + + return ( + f'' + 'xprobe: measured profiling overhead benchmarks' + 'Throughput ratio without versus with profiling across Python ' + 'external sampling, CPU sampling, uprobes, CUPTI, perf, and py-spy.' + f'' + + "".join(parts) + + "\n" + ) + + def main() -> None: if len(sys.argv) != 2: raise SystemExit("usage: render-readme-art.py ") @@ -385,6 +522,7 @@ def main() -> None: output.mkdir(parents=True, exist_ok=True) for theme in THEMES: (output / f"xprobe-flow-{theme}.svg").write_text(render(theme)) + (output / f"xprobe-bench-{theme}.svg").write_text(render_benchmarks(theme)) (output / "social-preview.svg").write_text(social_card()) From fefad6c9eb8c9311d7ba51420c2c1868f0c156f7 Mon Sep 17 00:00:00 2001 From: itdevwu Date: Tue, 1 Dec 2026 23:04:30 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=F0=9F=91=B7=20ci:=20install=20packages=20i?= =?UTF-8?q?n=20CUDA=20containers=20from=20the=20Azure=20mirror?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The CUDA images point apt at archive.ubuntu.com and security.ubuntu.com, which were unreachable from GitHub runners on 2026-12-01 after several outages in the previous two weeks. The container jobs in CI and release now use azure.archive.ubuntu.com, the mirror GitHub's runner hosts use. --- .github/workflows/ci.yml | 6 ++++++ .github/workflows/release.yml | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 753f1eb..3c80bea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,6 +55,12 @@ jobs: image: ${{ matrix.image }} steps: - uses: actions/checkout@v6 + # The CUDA images use Canonical's archive, which has had outages; the + # Azure mirror is what GitHub's runner hosts use. + - name: Use the Azure Ubuntu mirror + run: >- + sed -i -E 's#http://(archive|security)\.ubuntu\.com#http://azure.archive.ubuntu.com#' + /etc/apt/sources.list - name: Install native build tools run: >- apt-get update && apt-get install -y --no-install-recommends diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f5cc723..48719ff 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,6 +23,12 @@ jobs: image: ${{ matrix.image }} steps: - uses: actions/checkout@v6 + # The CUDA images use Canonical's archive, which has had outages; the + # Azure mirror is what GitHub's runner hosts use. + - name: Use the Azure Ubuntu mirror + run: >- + sed -i -E 's#http://(archive|security)\.ubuntu\.com#http://azure.archive.ubuntu.com#' + /etc/apt/sources.list - name: Install build tools env: DEBIAN_FRONTEND: noninteractive