From: Eric Blake <eblake@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>, qemu-block@nongnu.org
Cc: nsoffer@redhat.com, pl@kamp.de, qemu-devel@nongnu.org, mreitz@redhat.com
Subject: Re: [PATCH] qemu-img convert: Don't pre-zero images
Date: Mon, 22 Jun 2020 13:15:56 -0500 [thread overview]
Message-ID: <aed53e4a-dfae-fcca-3aa3-504835ed1ea2@redhat.com> (raw)
In-Reply-To: <20200622151203.35624-1-kwolf@redhat.com>
On 6/22/20 10:12 AM, Kevin Wolf wrote:
> Since commit 5a37b60a61c, qemu-img create will pre-zero the target image
> if it isn't already zero-initialised (most importantly, for host block
> devices, but also iscsi etc.), so that writing explicit zeros wouldn't
> be necessary later.
>
> This could speed up the operation significantly, in particular when the
> source image file was only sparsely populated. However, it also means
> that some block are written twice: Once when pre-zeroing them, and then
> when they are overwritten with actual data. On a full image, the
> pre-zeroing is wasted work because everything will be overwritten.
>
> In practice, write_zeroes typically turns out faster than writing
> explicit zero buffers, but slow enough that first zeroing everything and
> then overwriting parts can be a significant net loss.
>
> Meanwhile, qemu-img convert was rewritten in 690c7301600 and zero blocks
> are now written to the target using bdrv_co_pwrite_zeroes() if the
> target could be pre-zeroed. This way we already make use of the faster
> write_zeroes operation, but avoid writing any blocks twice.
>
> Remove the pre-zeroing because these days this former optimisation has
> actually turned into a pessimisation in the common case.
Indeed, it is both data-dependent (how sparse is the source) and
target-dependent (does the reduced I/O from a single pre-zeroing pass
outweigh the time spent on non-zero portions). I'm fine with dropping
this optimization, as we do not have proper heuristics to reliably
detect when it is actually going to be a win. (It would be nice if we
_could_ have reliable heuristics, but that's a story for another day)
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
prev parent reply other threads:[~2020-06-22 18:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-22 15:12 [PATCH] qemu-img convert: Don't pre-zero images Kevin Wolf
2020-06-22 15:20 ` Nir Soffer
2020-06-22 18:15 ` Eric Blake [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aed53e4a-dfae-fcca-3aa3-504835ed1ea2@redhat.com \
--to=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=nsoffer@redhat.com \
--cc=pl@kamp.de \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).