CodeWind
V2EX  ›  问与答

为什么我在 ubuntu22 上用 fio 测试 virtiofs 挂载目录不如 qcow2 虚拟机磁盘的速度呢?

  •  
  •   CodeWind · Oct 19, 2025 · 1795 views
    This topic created in 343 days ago, the information mentioned may be changed or developed.

    最近看到几篇关于 virtiofs 的帖子,似乎大家都在说他好,之前没了解过,遂折腾了一番,发现似乎速度在 lxc 下很快,在虚拟机中的速度似乎比不上 qcow2 的虚拟机磁盘?请教一下大家是不是用的不对。信息如下:

    测试命令:

    fio --name=randread --ioengine=libaio --direct=1 --bs=4k --rw=randread --numjobs=16 --iodepth=32 --size=1G --runtime=60 --directory=/data --group_reporting
    

    注:都是/data 目录,区别是该目录有无挂载 virtiofs 的目录。挂载是成功的,每次挂载完成后我都会新建一个文件测试。

    宿主机是 pve9 ,分别在 lxc 和 ubuntu 22 虚拟机上使用 virtiofs 挂载目录的方式测试,得出如下结论:

    测试位置 bw max bw min bw avg iops max iops min iops avg 是否 virtiofs
    宿主机 852602 809624 836449.15 213149 202402 209111.12 否
    LXC 容器 94312 64389 79575.80 23578 16095 19893.29 否
    LXC 容器 853197 821156 840081.10 213299 205288 210018.26 是
    vm 虚拟机 504696 266029 355102.08 126174 66505 88774.32 否
    vm 虚拟机 200392 3048 83236.69 50098 762 20809.05 是(未开 DirectIO)
    vm 虚拟机 196184 2616 58364.16 49046 654 14590.94 是(开 DirectIO)
    vm 虚拟机 186213 48762 93388.28 46550 12190 23345.66 NFS

    注:DirectIO 是 pve 上挂载 virtiofs 时的一个选项。

    4 replies  •  2025-10-20 11:14:46 +08:00
    oott123
        1
    oott123  
       Oct 19, 2025
    不如是正常的,毕竟共享文件系统比块设备复杂多了

    至于 lxc ,直接 mount 进去的话就完全没有额外开销吧,为啥要走 virtiofs ,真的走得通吗
    CodeWind
        2
    CodeWind  
    OP
       Oct 19, 2025
    @oott123 lxc 可以直接 mount ?我去了解一下,感谢
    CodeWind
        3
    CodeWind  
    OP
       Oct 19, 2025
    @oott123 看了一下,我之前是 pct set 进去的,其实也就是 mount ,不是 virtiofs
    nocwat
        4
    nocwat  
       Oct 20, 2025
    lxc 为啥还要用 virtiofs ,mount bind 就是本地性能。。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   870 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 18:59 · PVG 02:59 · LAX 11:59 · JFK 14:59
    ♥ Do have faith in what you're doing.