Virtio/Block/Latency

From KVM
Revision as of 03:03, 4 June 2010 by Stefanha (talk | contribs)

This page describes how virtio-blk latency can be measured. The aim is to build a picture of the latency at different layers of the virtualization stack for virtio-blk.

Benchmarks

Single-threaded read or write benchmarks are suitable for measuring virtio-blk latency. The guest should have 1 vcpu only, which simplifies the setup and analysis.

Instrumenting the stack

Guest

The single-threaded read/write benchmark prints the mean time per operation at the end. This number is the total latency including guest, host, and QEMU. All latency numbers from layers further down the stack should be smaller than the guest number.

Guest virtio-pci

The virtio-pci latency is the time from the virtqueue notify pio write until the vring interrupt. The guest performs the notify pio write in virtio-pci code. The vring interrupt comes from the PCI device in the form of a legacy interrupt or a message-signaled interrupt.

Host kvm

The kvm latency is the time from the virtqueue notify pio exit until the interrupt is set inside the guest. This number does not include vmexit/entry time.

QEMU virtio

The virtio latency inside QEMU is the time from virtqueue notify until the interrupt is raised. This accounts for time spent in QEMU servicing I/O.

* Run with 'simple' backend, enable virtio_queue_notify() and virtio_notify() trace events.
* Find vdev pointer for correct virtio-blk device in trace (should be easy because most requests will go to it).
* Use qemu_virtio.awk only on trace entries for the correct vdev.

QEMU paio

The paio latency is the time spent performing pread()/pwrite() syscalls. This should be similar to latency seen when running the benchmark on the host.

Host pread64

The pread64 latency is the duration of the pread64() in the host kernel.

Results

Host

Guest

Latency

The following diagram shows the time spent in the different layers of the virtualization stack:


Virtio-blk-latency.jpg

Layer Latency (ns) Delta (ns) Guest benchmark control (ns)
Guest benchmark 196528
Guest virtio-pci 170829 25699 202095
Host kvm.ko 163268 7561
QEMU virtio 159628 3640 205165
QEMU paio 130235 29393 202777
Host benchmark 128862