qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Change in qemu 2.12 causes qemu-img convert to NBD to write


From: Richard W.M. Jones
Subject: [Qemu-devel] Change in qemu 2.12 causes qemu-img convert to NBD to write more data
Date: Wed, 7 Nov 2018 12:13:19 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

(I'm not going to claim this is a bug, but it causes a large, easily
measurable performance regression in virt-v2v).

In qemu 2.10, when you do ‘qemu-img convert’ to an NBD target, qemu
interleaves write and zero requests.  We can observe this as follows:

  $ virt-builder fedora-28
  $ nbdkit --filter=log memory size=6G logfile=/tmp/log \
      --run './qemu-img convert ./fedora-28.img -n $nbd'
  $ grep '\.\.\.$' /tmp/log | sed 's/.*\([A-Z][a-z]*\).*/\1/' | uniq -c
      1 Write
      2 Zero
      1 Write
      3 Zero
      1 Write
      1 Zero
      1 Write
    [etc for over 1000 lines]

Looking at the log file in detail we can see it is writing serially
from the beginning to the end of the disk.

In qemu 2.12 this behaviour changed:

  $ nbdkit --filter=log memory size=6G logfile=/tmp/log \
      --run './qemu-img convert ./fedora-28.img -n $nbd'
  $ grep '\.\.\.$' /tmp/log | sed 's/.*\([A-Z][a-z]*\).*/\1/' | uniq -c
      193 Zero
     1246 Write

It now zeroes the whole disk up front and then writes data over the
top of the zeroed blocks.

The reason for the performance regression is that in the first case we
write 6G in total.  In the second case we write 6G of zeroes up front,
followed by the amount of data in the disk image (in this case the
test disk image contains 1G of non-sparse data, so we write about 7G
in total).

In real world cases this makes a great difference: we might have 100s
of G of data in the disk.  The ultimate backend storage (a Linux block
device) doesn't support efficient BLKZEROOUT so zeroing is pretty slow
too.

I bisected the change to the commit shown at the end of this email.

Any suggestions how to fix or work around this problem welcome.

Rich.


commit 9776f0db6a19a0510e89b7aae38190b4811c95ba
Author: Edgar Kaziakhmedov <address@hidden>
Date:   Thu Jan 18 14:51:58 2018 +0300

    nbd: implement bdrv_get_info callback
    
    Since mirror job supports efficient zero out target mechanism (see
    in mirror_dirty_init()), implement bdrv_get_info to make it work
    over NBD. Such improvement will allow using the largest chunk possible
    and will decrease the number of NBD_CMD_WRITE_ZEROES requests on the wire.
    
    Signed-off-by: Edgar Kaziakhmedov <address@hidden>
    Message-Id: <address@hidden>
    Reviewed-by: Paolo Bonzini <address@hidden>
    Signed-off-by: Eric Blake <address@hidden>


-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]