From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41615) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YnlT3-0002AP-HW for qemu-devel@nongnu.org; Thu, 30 Apr 2015 06:13:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YnlSz-0004Hn-FF for qemu-devel@nongnu.org; Thu, 30 Apr 2015 06:13:17 -0400 From: Alberto Garcia Date: Thu, 30 Apr 2015 13:11:39 +0300 Message-Id: Subject: [Qemu-devel] [PATCH 0/6] qcow2 L2/refcount cache improvements List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Stefan Hajnoczi Here are some improvements to the qcow2 L2/refcount cache code. The first one is that all cache tables are now allocated using a single memory block, as we discussed last week. Apart from a more efficient use of memory, this allows some additional optimizations so I took the chance to make other changes. - qcow2_cache_put() and qcow2_cache_entry_mark_dirty() are now O(1) - The eviction algorithm is now LRU. The previous one only works well with very small cache sizes. - qcow2_cache_find_entry_to_replace() is no longer necessary. - Lookups are faster now. In my tests with a preallocated 128MB L2 cache in an empty drive the new code is ~13% faster than the previous one (~43% if compiled without optimizations). This is a best-case scenario, if the cache is smaller or the drive is full of data the improvements are not so visible, but I believe the code is simpler now so I hope you find the changes worthwhile. Regards, Berto Alberto Garcia (6): qcow2: use one single memory block for the L2/refcount cache tables qcow2: simplify qcow2_cache_put() and qcow2_cache_entry_mark_dirty() qcow2: use an LRU algorithm to replace entries from the L2 cache qcow2: remove qcow2_cache_find_entry_to_replace() qcow2: use a hash to look for entries in the L2 cache qcow2: style fixes in qcow2-cache.c block/qcow2-cache.c | 149 +++++++++++++++++++++------------------------------- 1 file changed, 61 insertions(+), 88 deletions(-) -- 2.1.4