From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:55484) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QMMJO-0001Ia-Bd for qemu-devel@nongnu.org; Tue, 17 May 2011 11:35:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QMMJM-0004IU-D5 for qemu-devel@nongnu.org; Tue, 17 May 2011 11:35:54 -0400 Received: from mail-yw0-f45.google.com ([209.85.213.45]:43087) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QMMJM-0004IH-8P for qemu-devel@nongnu.org; Tue, 17 May 2011 11:35:52 -0400 Received: by ywl41 with SMTP id 41so227064ywl.4 for ; Tue, 17 May 2011 08:35:51 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: Date: Tue, 17 May 2011 16:35:50 +0100 Message-ID: From: Stefan Hajnoczi Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Qemu-devel] [PATCH] [qemu-img] CPU consuming optimization List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Dmitry Konishchev Cc: Kevin Wolf , stanislav.ievlev@gmail.com, qemu-devel@nongnu.org On Tue, May 17, 2011 at 3:33 PM, Dmitry Konishchev wrote: > Hi! I was wondering why qemu-img consumes so much CPU when it converts > one partially allocated qcow2 image to another qcow2 image and I've > written a patch which improves the situation a little. Please see http://wiki.qemu.org/Contribute/SubmitAPatch, which asks that patches are sent inline (not as attachments) for easy review and that you follow the coding style (see the CODING_STYLE file). Patches also need a Signed-off-by: line. The unrolled loop makes the function rely on len being a multiple of sizeof(long) * 4, otherwise it accesses beyond the end of sector[]. So for this use case it's okay but the function is generic anymore. GNU cp(1) tries to detect holes in files and image formats could tell us about unallocated regions using bdrv_is_allocated(). So I think there are ways to avoid comparing so much data in the first place, if you are interested in looking into that. Stefan