Received: from eggs.gnu.org ([2001:4830:134:3::10]:58842) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YkvmI-0007Ro-CQ for qemu-devel@nongnu.org; Wed, 22 Apr 2015 10:37:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YkvmE-000879-4g for qemu-devel@nongnu.org; Wed, 22 Apr 2015 10:37:26 -0400 From: Alberto Garcia In-Reply-To: <20150422102602.GA20029@stefanha-thinkpad.redhat.com> References: <1429629639-14328-1-git-send-email-berto@igalia.com> <20150422102602.GA20029@stefanha-thinkpad.redhat.com> Date: Wed, 22 Apr 2015 16:37:15 +0200 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [Qemu-block] [PATCH] qcow2: do lazy allocation of the L2 cache List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org On Wed 22 Apr 2015 12:26:02 PM CEST, Stefan Hajnoczi wrote: >> Large disk images need large L2 caches in order to maximize their I/O >> performance. However setting a correct size for the cache is not >> necessarily easy since apart from the image size, it also depends on >> other factors like its usage patterns or whether it's part of a >> backing chain. >> >> In order to be able to set a very large cache size to cover the >> worst-case scenarios and yet prevent an unnecessary waste of memory, >> this patch modifies the qcow2 cache algorithm so the memory for each >> entry is allocated only when it's actually needed. >> >> This also improves the scenarios with smaller images: the current >> default L2 cache size can map a whole 8GB disk, so those smaller than >> that are allocating cache memory that can never be used. > > What measurable improvement does this patch make? > > Buffers allocated upfront are not touched, so they don't actually > consume physical memory. For a cache size of 128MB, the PSS is actually ~10MB larger without the patch, which seems to come from posix_memalign(). But yeah, for smaller caches there's no difference. I should probably add a timer to free unused cache entries after some expiration time. What do you think? Berto