From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: qemu-block@nongnu.org
Cc: fam@euphon.net, kwolf@redhat.com, armbru@redhat.com,
qemu-devel@nongnu.org, mreitz@redhat.com, nsoffer@redhat.com,
stefanha@redhat.com, den@openvz.org
Subject: Re: [PATCH v5 07/10] block: introduce preallocate filter
Date: Wed, 26 Aug 2020 10:06:04 +0300 [thread overview]
Message-ID: <4000e3f3-1150-5538-7c1a-4df2d278bd8b@virtuozzo.com> (raw)
In-Reply-To: <4e72d12f-0824-cc2c-4f20-be1491d69069@virtuozzo.com>
24.08.2020 20:52, Vladimir Sementsov-Ogievskiy wrote:
> 21.08.2020 17:11, Vladimir Sementsov-Ogievskiy wrote:
>> It's intended to be inserted between format and protocol nodes to
>> preallocate additional space (expanding protocol file) on writes
>> crossing EOF. It improves performance for file-systems with slow
>> allocation.
>>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>> ---
>> docs/system/qemu-block-drivers.rst.inc | 26 +++
>> qapi/block-core.json | 20 +-
>> block/preallocate.c | 291 +++++++++++++++++++++++++
>> block/Makefile.objs | 1 +
>> 4 files changed, 337 insertions(+), 1 deletion(-)
>> create mode 100644 block/preallocate.c
>>
>> diff --git a/docs/system/qemu-block-drivers.rst.inc b/docs/system/qemu-block-drivers.rst.inc
>> index b052a6d14e..5e8a35c571 100644
>> --- a/docs/system/qemu-block-drivers.rst.inc
>> +++ b/docs/system/qemu-block-drivers.rst.inc
>> @@ -952,3 +952,29 @@ on host and see if there are locks held by the QEMU process on the image file.
>> More than one byte could be locked by the QEMU instance, each byte of which
>> reflects a particular permission that is acquired or protected by the running
>> block driver.
>> +
>
> [..]
>
>> +
>> +static coroutine_fn int preallocate_co_preadv_part(
>> + BlockDriverState *bs, uint64_t offset, uint64_t bytes,
>> + QEMUIOVector *qiov, size_t qiov_offset, int flags)
>> +{
>> + return bdrv_co_preadv_part(bs->file, offset, bytes, qiov, qiov_offset,
>> + flags);
>> +}
>> +
>> +static int coroutine_fn preallocate_co_pdiscard(BlockDriverState *bs,
>> + int64_t offset, int bytes)
>> +{
>> + return bdrv_co_pdiscard(bs->file, offset, bytes);
>> +}
>> +
>> +static bool coroutine_fn do_preallocate(BlockDriverState *bs, int64_t offset,
>> + int64_t bytes, bool write_zero)
>> +{
>> + BDRVPreallocateState *s = bs->opaque;
>> + int64_t len, start, end;
>
> int64_t old_data_end = s->data_end;
>
>> +
>> + if (!s->active) {
>> + return false;
>> + }
>> +
>> + if (s->data_end >= 0) {
>> + s->data_end = MAX(s->data_end,
>> + QEMU_ALIGN_UP(offset + bytes, BDRV_SECTOR_SIZE));
>> + }
>> +
>> + len = bdrv_getlength(bs->file->bs);
>> + if (len < 0) {
>> + return false;
>
> return old_data_end >= 0 && offset >= old_data_end;
>
>
> And with this small improvement we make the following test 20% faster (ssd, ext4):
>
> ./qemu-img create -f qcow2 $img 16G; ./qemu-img bench -c 150000 -d 64 -f qcow2 -s 16k -t none -n -w $img;
>
> (assume additional patch which inserts the filter).
>
> Great! So, preallocation is generally good idea, not only for vstorage.
>
> What about inserting the filter by default?
>
> I'll come tomorrow with more complete test results.
>
Some results:
the two commands to compare:
img=/ssd/x.qcow2; for i in {1..5}; do ./qemu-img create -f qcow2 $img 16G; ./qemu-img bench -c 150000 -d 64 -s 16k -t none -n -w --image-opts driver=qcow2,file.filename=$img; done
img=/ssd/x.qcow2; for i in {1..5}; do ./qemu-img create -f qcow2 $img 16G; ./qemu-img bench -c 150000 -d 64 -s 16k -t none -n -w --image-opts driver=qcow2,file.driver=preallocate,file.file.filename=$img; done
no-filter with-filter
ssd
ext4: 6.94s 5.53s (-20%)
xfs: 6.9s 25s (+262%)
hdd (with -c 45000)
ext4: 8.23s 12.75s (+55%)
xfs: 7.79s 25.4s (+226%)
vstorage (some custom distributed fs), with -c 4000 over ext4 over ssd: 42.9s ~> 0.27s, more than 150 times faster with filter!
same, with -c 2000 over ext4 over hdd: 22.8s ~> 0.53s, ~43 times faster.
So, we do have large improvement for the vstorage (some custom distributed fs), which is our main target. And there is a significant improvement for ext4 over ssd. And (a lot more) significant degradation in other cases. For sure, we can't insert the filter by default, but it is useful.
--
Best regards,
Vladimir
next prev parent reply other threads:[~2020-08-26 7:06 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-21 14:11 [PATCH v5 00/10] preallocate filter Vladimir Sementsov-Ogievskiy
2020-08-21 14:11 ` [PATCH v5 01/10] block: simplify comment to BDRV_REQ_SERIALISING Vladimir Sementsov-Ogievskiy
2020-08-21 14:11 ` [PATCH v5 02/10] block/io.c: drop assertion on double waiting for request serialisation Vladimir Sementsov-Ogievskiy
2020-08-21 14:11 ` [PATCH v5 03/10] block/io: split out bdrv_find_conflicting_request Vladimir Sementsov-Ogievskiy
2020-08-21 14:11 ` [PATCH v5 04/10] block/io: bdrv_wait_serialising_requests_locked: drop extra bs arg Vladimir Sementsov-Ogievskiy
2020-08-21 14:11 ` [PATCH v5 05/10] block: bdrv_mark_request_serialising: split non-waiting function Vladimir Sementsov-Ogievskiy
2020-08-25 12:43 ` Max Reitz
2020-08-21 14:11 ` [PATCH v5 06/10] block: introduce BDRV_REQ_NO_WAIT flag Vladimir Sementsov-Ogievskiy
2020-08-25 13:10 ` Max Reitz
2020-08-26 6:26 ` Vladimir Sementsov-Ogievskiy
2020-08-26 8:36 ` Max Reitz
2020-08-26 8:57 ` Vladimir Sementsov-Ogievskiy
2020-08-21 14:11 ` [PATCH v5 07/10] block: introduce preallocate filter Vladimir Sementsov-Ogievskiy
2020-08-24 17:52 ` Vladimir Sementsov-Ogievskiy
2020-08-26 7:06 ` Vladimir Sementsov-Ogievskiy [this message]
2020-08-25 15:11 ` Max Reitz
2020-08-26 6:49 ` Vladimir Sementsov-Ogievskiy
2020-08-26 8:52 ` Max Reitz
2020-08-26 9:15 ` Vladimir Sementsov-Ogievskiy
2020-08-26 9:58 ` Max Reitz
2020-08-26 11:29 ` Vladimir Sementsov-Ogievskiy
2020-08-26 13:51 ` David Edmondson
2020-08-27 9:19 ` Vladimir Sementsov-Ogievskiy
2020-08-21 14:11 ` [PATCH v5 08/10] iotests.py: add verify_o_direct helper Vladimir Sementsov-Ogievskiy
2020-08-21 17:29 ` Nir Soffer
2020-08-21 14:11 ` [PATCH v5 09/10] iotests.py: add filter_img_check Vladimir Sementsov-Ogievskiy
2020-08-21 14:11 ` [PATCH v5 10/10] iotests: add 298 to test new preallocate filter driver Vladimir Sementsov-Ogievskiy
2020-08-27 21:08 ` [PATCH v5 00/10] preallocate filter Vladimir Sementsov-Ogievskiy
2020-09-01 15:07 ` Max Reitz
2020-09-17 9:00 ` Vladimir Sementsov-Ogievskiy
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=4000e3f3-1150-5538-7c1a-4df2d278bd8b@virtuozzo.com \
--to=vsementsov@virtuozzo.com \
--cc=armbru@redhat.com \
--cc=den@openvz.org \
--cc=fam@euphon.net \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=nsoffer@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).