[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v4 14/23] qemu-img: Speed up compare on pre-allo
From: |
John Snow |
Subject: |
Re: [Qemu-devel] [PATCH v4 14/23] qemu-img: Speed up compare on pre-allocated larger file |
Date: |
Wed, 27 Sep 2017 16:54:55 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 |
On 09/13/2017 12:03 PM, Eric Blake wrote:
> Compare the following images with all-zero contents:
> $ truncate --size 1M A
> $ qemu-img create -f qcow2 -o preallocation=off B 1G
> $ qemu-img create -f qcow2 -o preallocation=metadata C 1G
>
> On my machine, the difference is noticeable for pre-patch speeds,
> with more than an order of magnitude in difference caused by the
> choice of preallocation in the qcow2 file:
>
> $ time ./qemu-img compare -f raw -F qcow2 A B
> Warning: Image size mismatch!
> Images are identical.
>
> real 0m0.014s
> user 0m0.007s
> sys 0m0.007s
>
> $ time ./qemu-img compare -f raw -F qcow2 A C
> Warning: Image size mismatch!
> Images are identical.
>
> real 0m0.341s
> user 0m0.144s
> sys 0m0.188s
>
> Why? Because bdrv_is_allocated() returns false for image B but
> true for image C, throwing away the fact that both images know
> via lseek(SEEK_HOLE) that the entire image still reads as zero.
> From there, qemu-img ends up calling bdrv_pread() for every byte
> of the tail, instead of quickly looking for the next allocation.
> The solution: use block_status instead of is_allocated, giving:
>
> $ time ./qemu-img compare -f raw -F qcow2 A C
> Warning: Image size mismatch!
> Images are identical.
>
> real 0m0.014s
> user 0m0.011s
> sys 0m0.003s
>
> which is on par with the speeds for no pre-allocation.
>
> Signed-off-by: Eric Blake <address@hidden>
Makes good sense to me.
Reviewed-by: John Snow <address@hidden>
- Re: [Qemu-devel] [PATCH v4 07/23] block: Convert bdrv_get_block_status() to bytes, (continued)
- [Qemu-devel] [PATCH v4 08/23] block: Switch bdrv_co_get_block_status() to byte-based, Eric Blake, 2017/09/13
- [Qemu-devel] [PATCH v4 11/23] block: Switch bdrv_co_get_block_status_above() to byte-based, Eric Blake, 2017/09/13
- [Qemu-devel] [PATCH v4 10/23] block: Switch bdrv_common_block_status_above() to byte-based, Eric Blake, 2017/09/13
- [Qemu-devel] [PATCH v4 09/23] block: Switch BdrvCoGetBlockStatusData to byte-based, Eric Blake, 2017/09/13
- [Qemu-devel] [PATCH v4 14/23] qemu-img: Speed up compare on pre-allocated larger file, Eric Blake, 2017/09/13
- Re: [Qemu-devel] [PATCH v4 14/23] qemu-img: Speed up compare on pre-allocated larger file,
John Snow <=
- [Qemu-devel] [PATCH v4 15/23] qemu-img: Add find_nonzero(), Eric Blake, 2017/09/13
- [Qemu-devel] [PATCH v4 16/23] qemu-img: Drop redundant error message in compare, Eric Blake, 2017/09/13
- [Qemu-devel] [PATCH v4 13/23] qemu-img: Simplify logic in img_compare(), Eric Blake, 2017/09/13
- [Qemu-devel] [PATCH v4 12/23] block: Convert bdrv_get_block_status_above() to bytes, Eric Blake, 2017/09/13