Performance¶
How fast each path is, measured with the test suite. The numbers show orders of magnitude, not a benchmark: the guests run a debug kernel (lockdep, KFENCE, UBSAN), and everything shares one laptop CPU (i3-12100F, 4 cores, KVM, WSL2).
Paths¶
A guest reaches the peer's memory in two ways:
- CPU accesses through a memory window (
ntb_transportwithout DMA,ntb_perfCPU mode, your own driver writing to the BAR). On the message path every access is a VM exit and a message to the peer. On the fast path (fast-mw=on, QEMU device only) the window is the peer's RAM, mapped into the guest; accesses run at memory speed. - The DMA engine copies between local RAM and the window. On the fast path it copies through the same mapping; otherwise it sends 64 KiB chunks as messages.
Results¶
| Measurement | QEMU device, fast-mw=on |
QEMU device, fast-mw=off |
ntbd |
|---|---|---|---|
CPU writes through a window, 1 MiB (qntb_dmatest) |
~500 MB/s | ~0.2 MB/s | ~0.1 MB/s |
ntb_netdev without DMA (p3-netdev) |
12–16 MiB/s | 0.4 MiB/s | 0.2 MiB/s |
ntb_netdev with DMA (p3-netdev-dma) |
30–37 MiB/s | 30 MiB/s | 27–34 MiB/s |
ntb_perf, CPU (p4-perf) |
430–520 MB/s | — (too slow to report) | — |
ntb_perf, DMA (p4-perf) |
2000–2800 MB/s | ~400 MB/s | 2400–3000 MB/s |
ntb_netdev with DMA hardly changes: in these guests it is bound by the
network stack and the debug kernel, not by the copy.
Reproducing¶
NTB_IMPL=qemu scripts/run-all.sh # fast path
FAST_MW=off NTB_IMPL=qemu scripts/run-all.sh # message path
scripts/run-all.sh # ntbd
The rates appear in the summary; the CPU write rate is in
out/run-all/p5-dma-adversarial/result-a.txt.
Which path to use¶
Use the fast path when both QEMUs run under KVM with shared guest RAM and trust each other (see the QEMU device). The message path works everywhere and is fine for control traffic and tests; for bulk data on it, use the DMA engine.