Description:

I haven't tested filesystem passthrough for virtual machines for long ago. It has been slow for years. But several months ago I watched KVM Forum videos and found out that virtiofs (don't confuse with virtfs) become ready for usage. After planned systems upgrades I decided to compare plan9 and virtiofs for speed (caches are dropped, copying from RAM):

Versions:

kernel 5.4.46
qemu 5.0.0
libvirt 6.2.0


Preparations:

mount -o size=5G -t tmpfs none /mnt/ram
dd if=/dev/urandom of=/mnt/ram/file bs=1M count=4096


plan9 (95-100MB/s):

mkdir -p /tmp/9p
mount -t 9p -o trans=virtio,version=9p2000.L /host9p /tmp/9p
echo 3 > /proc/sys/vm/drop_caches
rsync --progress /mnt/ram/file /tmp/9p/file


virtiofs (200-300MB/s):

mkdir -p /tmp/virtiofs
mount -t virtiofs hostvirtiofs /mnt/virtiofs
echo 3 > /proc/sys/vm/drop_caches
rsync --progress /mnt/ram/file /mnt/virtiofs/file

I got interested and did some fio tests:

[readtest]
blocksize=4k
filename=file
rw=randread
direct=1
buffered=0
ioengine=libaio
iodepth=32
[writetest]
blocksize=4k
filename=file
rw=randwrite
direct=1
buffered=0
ioengine=libaio
iodepth=32

fio results:

read: IOPS=71.6k, BW=280MiB/s (293MB/s)(4096MiB/14636msec)
clat (usec): min=47, max=10906, avg=433.51, stdev=731.51

write: IOPS=121k, BW=472MiB/s (495MB/s)(4096MiB/8675msec); 0 zone resets
clat (usec): min=62, max=8733, avg=257.51, stdev=163.34