From 72e80b89015bab196f0f0e83b12b0eee75fa0574 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Date: Mon, 11 May 2015 15:54:53 +0300 Subject: qcow2: use one single memory block for the L2/refcount cache tables The qcow2 L2/refcount cache contains one separate table for each cache entry. Doing one allocation per table adds unnecessary overhead and it also requires us to store the address of each table separately. Since the size of the cache is constant during its lifetime, it's better to have an array that contains all the tables using one single allocation. In my tests measuring freshly created caches with sizes 128MB (L2) and 32MB (refcount) this uses around 10MB of RAM less. Signed-off-by: Alberto Garcia Reviewed-by: Stefan Hajnoczi Reviewed-by: Max Reitz Signed-off-by: Kevin Wolf --- block/qcow2.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'block/qcow2.h') diff --git a/block/qcow2.h b/block/qcow2.h index 422b825138..5d0995f03d 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -574,7 +574,8 @@ int qcow2_read_snapshots(BlockDriverState *bs); Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables); int qcow2_cache_destroy(BlockDriverState* bs, Qcow2Cache *c); -void qcow2_cache_entry_mark_dirty(Qcow2Cache *c, void *table); +void qcow2_cache_entry_mark_dirty(BlockDriverState *bs, Qcow2Cache *c, + void *table); int qcow2_cache_flush(BlockDriverState *bs, Qcow2Cache *c); int qcow2_cache_set_dependency(BlockDriverState *bs, Qcow2Cache *c, Qcow2Cache *dependency); -- cgit v1.2.3