[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 1/2] qcow2: Give the refcount cache the minim
From: |
Max Reitz |
Subject: |
Re: [Qemu-devel] [PATCH v2 1/2] qcow2: Give the refcount cache the minimum possible size by default |
Date: |
Mon, 16 Apr 2018 18:14:14 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 |
On 2018-03-14 09:29, Alberto Garcia wrote:
> The L2 and refcount caches have default sizes that can be overridden
> using the l2-cache-size and refcount-cache-size (an additional
> parameter named cache-size sets the combined size of both caches).
>
> Unless forced by one of the aforementioned parameters, QEMU will set
> the unspecified sizes so that the L2 cache is 4 times larger than the
> refcount cache.
>
> This is based on the premise that the refcount metadata needs to be
> only a fourth of the L2 metadata to cover the same amount of disk
> space. This is incorrect for two reasons:
>
> a) The amount of disk covered by an L2 table depends solely on the
> cluster size, but in the case of a refcount block it depends on
> the cluster size *and* the width of each refcount entry.
> The 4/1 ratio is only valid with 16-bit entries (the default).
>
> b) When we talk about disk space and L2 tables we are talking about
> guest space (L2 tables map guest clusters to host clusters),
> whereas refcount blocks are used for host clusters (including
> L1/L2 tables and the refcount blocks themselves). On a fully
> populated (and uncompressed) qcow2 file, image size > virtual size
> so there are more refcount entries than L2 entries.
>
> Problem (a) could be fixed by adjusting the algorithm to take into
> account the refcount entry width. Problem (b) could be fixed by
> increasing a bit the refcount cache size to account for the clusters
> used for qcow2 metadata.
>
> However this patch takes a completely different approach and instead
> of keeping a ratio between both cache sizes it assigns as much as
> possible to the L2 cache and the remainder to the refcount cache.
>
> The reason is that L2 tables are used for every single I/O request
> from the guest and the effect of increasing the cache is significant
> and clearly measurable. Refcount blocks are however only used for
> cluster allocation and internal snapshots and in practice are accessed
> sequentially in most cases, so the effect of increasing the cache is
> negligible (even when doing random writes from the guest).
>
> So, make the refcount cache as small as possible unless the user
> explicitly asks for a larger one.
>
> Signed-off-by: Alberto Garcia <address@hidden>
> Reviewed-by: Eric Blake <address@hidden>
> ---
> block/qcow2.c | 31 +++++++++++++++++++------------
> block/qcow2.h | 4 ----
> tests/qemu-iotests/137.out | 2 +-
> 3 files changed, 20 insertions(+), 17 deletions(-)
Reviewed-by: Max Reitz <address@hidden>
signature.asc
Description: OpenPGP digital signature