summaryrefslogtreecommitdiffstats
path: root/docs/PERFORMANCE.md
diff options
context:
space:
mode:
authorOpen-IOV <dev@open-iov.org>2026-09-23 05:44:08 -0400
committerOpen-IOV <dev@open-iov.org>2026-09-23 05:46:43 -0400
commit68cdd7728a7cc6715bbbff7decfe2b11c3bdf558 (patch)
tree3dc8ce2e6af313a97ec6852f5c663a9a93665d2e /docs/PERFORMANCE.md
downloadopen-iov-68cdd7728a7cc6715bbbff7decfe2b11c3bdf558.tar.gz
open-iov-68cdd7728a7cc6715bbbff7decfe2b11c3bdf558.zip
Open-IOV: initial public release
Open-IOV virtualizes NVIDIA GPUs so that unmodified guest drivers run with real GPU functionality - CUDA first, 3D and video to follow - on unmodified hosts, without a proprietary vGPU license and without patching any driver, firmware or hypervisor. Core principle: emulate the interface, pass through the work. kernel/ open-iov-vfio.ko - host VFIO mdev driver: virtual GPU device (PCI config space, BAR shadows, MSI-X), GSP boot emulation, GSP-RM message-queue/RPC emulation, memory model (GPU-VA to guest-PA discovery) and the semaphore-completion service that advances guest UVM progress. userspace/ libiov.so management API and examples. tools/ guest diagnostics, firmware analysis wrappers, RM probes. scripts/ stack manager, VM harness, build/load/test automation. config/ hardware/version profiles (the portability surface). docs/ documentation tree - start at docs/README.md. wiki/ long-form firmware and protocol deep dives. Status: initialization works end to end for a stock 570.144 Linux guest on Turing (TU104): driver probe, nvidia-smi, the full GSP-RM control battery, object creation and the early CUDA/UVM start-up path. GPU work forwarding - the step that makes CUDA kernels execute on real hardware - is the active work item; see docs/04-implementation/01-known-knowns-and-unknowns.md. License: BSD-3-Clause for the project; GPL-2.0 for kernel modules that link GPL-only kernel interfaces. See LICENSE and docs/09-reference/legal-and-licensing.md.
Diffstat (limited to 'docs/PERFORMANCE.md')
-rw-r--r--docs/PERFORMANCE.md98
1 files changed, 98 insertions, 0 deletions
diff --git a/docs/PERFORMANCE.md b/docs/PERFORMANCE.md
new file mode 100644
index 0000000..6077920
--- /dev/null
+++ b/docs/PERFORMANCE.md
@@ -0,0 +1,98 @@
+# Open-IOV Performance Testing & A/B Methodology
+
+> How we measure vGPU performance against bare metal, interpret the results,
+> and keep overhead on the critical path honest. **Run correctness first**
+> (`docs/DEBUGGING.md` §5) — numbers from a half-working stack are noise.
+
+---
+
+## 1. What overhead is acceptable (targets)
+
+| Path | Target | Why |
+|------|--------|-----|
+| GSP RPC round-trip (doorbell→response→MSI-X) | < 50 µs (stretch: < 10 µs) | every driver op goes through here |
+| MSI-X injection (eventfd → guest handler) | < 5 µs | completion latency dominates |
+| Guest BAR0 MMIO read/write | < 2 µs (shadow RAM) | hot path for register polling |
+| CUDA kernel launch (added overhead vs bare metal) | < 10% | user-visible |
+| Memory alloc/map RPCs | < 100 µs | setup-time, amortized |
+| CUDA compute throughput | ≥ 95% of bare metal | GPU-bound, should be ~free |
+| Graphics (frame rate) | ≥ 90% of bare metal | swapchain + submission overhead |
+
+## 2. The A/B rule
+
+Every measurement runs **twice on the same machine, same boot if possible**:
+
+- **A (bare metal)**: workload on the physical GPU via the host's stock
+ driver (or our OpenRM nvidia.ko directly on the hardware).
+- **B (vGPU)**: identical workload in the guest on the emulated vGPU.
+
+Same binary, same input sizes, same environment (governor, clocks, hugepages).
+Report **B/A ratio %** — never absolute numbers alone.
+
+One variable at a time. If B regresses, you changed the stack, the workload,
+or the machine — find which before optimizing.
+
+## 3. Microbenchmarks (build these first)
+
+1. **RPC round-trip**: from the guest, submit a DEBUG/NOOP-ish RPC in a loop;
+ time doorbell-write → response-visible. Host side: `gsp_emu_get_stats()`
+ gives `total_latency_ns` and counts — divide for per-RPC host cost.
+ (Add `trace_printk` in `gsp_emu_dispatch_rpc` entry/exit for distribution;
+ read via `/sys/kernel/debug/tracing/trace`.)
+2. **MSI-X latency**: timestamp (guest TSC) at RPC submit → in the guest
+ driver's interrupt handler. Compare with the host eventfd_signal timestamp.
+3. **BAR0 shadow read latency**: guest loops reading a shadow register;
+ expect ~memory speed (uncached, so ~100-300 ns) — anything ≥ 1 µs means
+ you're trapping somewhere you shouldn't.
+4. **Doorbell polling cost**: host `top`/`perf` on `gsp_emu_N` — the adaptive
+ poll (busy → 50-100 µs sleep) should sit at ~0% CPU when idle, and react
+ within one sleep quantum under load. Tune `GSP_EMU_POLL_*` only with data.
+
+## 4. Workload benchmarks
+
+Runner: `tools/benchmark_infrastructure.sh` (extend it; keep the A/B pattern).
+In-guest execution goes through the harness (`vgpu_vm.py exec`) or the guest
+test agent (`tools/guest_agent/`).
+
+| Suite | What | Pass criterion |
+|-------|------|----------------|
+| `cuda-samples vectorAdd` | smoke + element-wise throughput | correct result; ≥ 95% B/A |
+| `simpleCUBLAS` | SGEMM TFLOPS | ≥ 95% B/A |
+| `nvbandwidth` (if available) | H2D/D2H/device copy GB/s | report; DMA path validation |
+| `glxgears -info` / a real GL app | frame rate | ≥ 90% B/A |
+| `nvenc`/`nvdec` sample | transcode fps | functional (perf later) |
+| PyTorch CUDA op (matmul loop) | end-to-end framework | ≥ 90% B/A |
+
+Always log: guest/host driver versions, GPU clocks (`nvidia-smi -q -d CLOCK`
+both sides — throttling skews everything), and the command lines.
+
+## 5. Where the overhead lives (profile in this order)
+
+1. **RPC dispatch** — the single biggest lever. Everything the guest driver
+ does funnels through the emulation thread.
+2. **Doorbell polling cadence** — too slow = latency; too hot = host CPU burn.
+3. **eventfd/MSI-X delivery** — measure, don't assume.
+4. **BAR0 uncached semantics** — shadow is UC for the guest; that's
+ MMIO-correct but slow for large reads. If the driver bulk-reads shadow,
+ consider caching-safe sub-regions.
+5. **Memory model gap** (ALLOC host-pages vs BAR1 direct VRAM) — see
+ `docs/GSP_EMULATION_ARCHITECTURE.md` §3. Until unified, DMA-heavy
+ workloads are not representative.
+
+## 6. Optimizing safely
+
+- Change one thing, re-run the A/B pair, keep the numbers with the commit.
+- Never optimize off bare-metal-only data: the goal is B/A, not A.
+- If a change makes B faster but breaks the §5 validation checklist in
+ `docs/DEBUGGING.md`, it doesn't count.
+- Record results in `STATE.md` (date, versions, B/A ratios) so regressions
+ are visible across commits.
+
+## 7. Reporting template
+
+```
+Date / commit / versions (guest=host=firmware=emulation):
+Machine / GPU / clocks locked?:
+Test, unit, A (bare), B (vGPU), B/A %:
+Notes (what changed vs last run):
+```