[RFC 0/2] block/qcow2: Improve I/O performance in write-through cache mode

zhangjiaji via posted 2 patches 3 weeks, 1 day ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20251023122457.2610426-1-zhangjiaji1@huawei.com
Maintainers: Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>
block/qcow2-cache.c   | 40 +++++++++++++++++++++++++++++++++++++---
block/qcow2-cluster.c | 15 +++++++++++++++
block/qcow2.h         |  3 +++
3 files changed, 55 insertions(+), 3 deletions(-)
[RFC 0/2] block/qcow2: Improve I/O performance in write-through cache mode
Posted by zhangjiaji via 3 weeks, 1 day ago
From: Zhu Yangyang <zhuyangyang14@huawei.com>

I'm working on optimizing IO performance in writethrough cache mode. 
I've observed poor random write performance with the qcow2 driver, 
primarily because the writethrough mode executes a flush after 
each write operation. This flush triggers qcow2_write_caches(), and even 
with minimal changes in the cache, it refreshes the entire L2 table. 
This IO amplification becomes particularly noticeable when the L2 table size
is large.

My current approach involves writing to the cache immediately after 
updating an L2 entry, which would allow us to flush only the actually 
modified portions.

Initial test results are as follows:
The host uses an SSD disk with a 200GB qcow2 image file, created with
default configurations.
The virtual machine was tested using fio with the following command:
fio -ioengine=libaio -bs=4K -direct=1 -thread -numjobs=1 -rw=randwrite 
-size=200G -filename=/dev/vda -name=test -iodepth=32 -time_based -runtime=120

Before optimization:
IOPS: 3110, latency: 10.2ms
After optimization:
IOPS: 4964, latency: 6.4ms
Performance improved by 59.6%.

This patch is still quite preliminary, and I would greatly appreciate 
any comments or suggestions from the community.

Thank you very much!

Zhu Yangyang (2):
  block/qcow2-cache: Introduce qcow2_write_l2_entry()
  block/qcow2: Improve I/O performance in write-through cache mode for
    qcow2 driver

 block/qcow2-cache.c   | 40 +++++++++++++++++++++++++++++++++++++---
 block/qcow2-cluster.c | 15 +++++++++++++++
 block/qcow2.h         |  3 +++
 3 files changed, 55 insertions(+), 3 deletions(-)

-- 
2.33.0