From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:49940) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QWonM-0006gD-1b for qemu-devel@nongnu.org; Wed, 15 Jun 2011 08:02:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QWonK-0003mR-Hz for qemu-devel@nongnu.org; Wed, 15 Jun 2011 08:02:03 -0400 Received: from mail-yi0-f45.google.com ([209.85.218.45]:35904) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QWonK-0003m3-0T for qemu-devel@nongnu.org; Wed, 15 Jun 2011 08:02:02 -0400 Received: by yia25 with SMTP id 25so240152yia.4 for ; Wed, 15 Jun 2011 05:02:01 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <1307544625-22907-1-git-send-email-konishchev@gmail.com> <20110613082608.GA25582@stefanha-thinkpad.localdomain> Date: Wed, 15 Jun 2011 13:02:01 +0100 Message-ID: From: Stefan Hajnoczi Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [Qemu-devel] [PATCH] CPU consumption optimization of 'qemu-img convert' using bdrv_is_allocated() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Dmitry Konishchev Cc: Kevin Wolf , qemu-devel@nongnu.org On Wed, Jun 15, 2011 at 10:50 AM, Dmitry Konishchev wrote: > On Wed, Jun 15, 2011 at 12:39 PM, Stefan Hajnoczi wrote: >> Why is bdrv_get_geometry() slow? > > Mmm.. Frankly, I haven't looked so deep, but it is going to be slow at > least for raw images due to using lseek(). We need to fully understand performance before applying optimizations on top. Otherwise it is possible to paper over a problem while leaving the root cause unsolved. Avoiding lseek(2) is very important, not just for qemu-img but also for running VMs. lseek(2) should only be invoked if the image is growable/removable. When I run a VM from a virtio-blk raw image I see no lseek(2) calls. On the host: strace -p $pid_of_qemu -f Inside the guest: dd if=/dev/vda of=/dev/null iflag=direct I see pread(2) from the posix-aio-compat.c worker threads but no lseek(2). The total_sectors cached value is being used. Does strace(1) show lseek(2) on your host? Stefan