From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:32774) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R3NnU-0002dW-M6 for qemu-devel@nongnu.org; Tue, 13 Sep 2011 03:52:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R3NnT-0006i7-J1 for qemu-devel@nongnu.org; Tue, 13 Sep 2011 03:52:48 -0400 Received: from mail-bw0-f45.google.com ([209.85.214.45]:34439) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R3NnT-0006i1-89 for qemu-devel@nongnu.org; Tue, 13 Sep 2011 03:52:47 -0400 Received: by bkbzv15 with SMTP id zv15so263370bkb.4 for ; Tue, 13 Sep 2011 00:52:45 -0700 (PDT) From: Frediano Ziglio Date: Tue, 13 Sep 2011 09:53:06 +0200 Message-Id: <1315900388-6448-1-git-send-email-freddy77@gmail.com> Subject: [Qemu-devel] [PATCH][RFC][0/2] REF+/REF- optimization List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: kwolf@redhat.com Cc: qemu-devel@nongnu.org, Frediano Ziglio These patches try to trade-off between leaks and speed for clusters refcounts. Refcount increments (REF+ or refp) are handled in a different way from decrements (REF- or refm). The reason it that posting or not flushing a REF- cause "just" a leak while posting a REF+ cause a corruption. To optimize REF- I just used an array to store offsets then when a flush is requested or array reach a limit (currently 1022) the array is sorted and written to disk. I use an array with offset instead of ranges to support compression (an offset could appear multiple times in the array). I consider this patch quite ready. To optimize REF+ I mark a range as allocated and use this range to get new ones (avoiding writing refcount to disk). When a flush is requested or in some situations (like snapshot) this cache is disabled and flushed (written as REF-). I do not consider this patch ready, it works and pass all io-tests but for instance I would avoid allocating new clusters for refcount during preallocation. End speed up is quite visible allocating clusters (more then 20%). Frediano Ziglio (2): qcow2: optimize refminus updates qcow2: ref+ optimization block/qcow2-refcount.c | 270 +++++++++++++++++++++++++++++++++++++++++++++--- block/qcow2.c | 2 + block/qcow2.h | 16 +++ 3 files changed, 275 insertions(+), 13 deletions(-)