From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34425) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XGmWW-000310-C6 for qemu-devel@nongnu.org; Mon, 11 Aug 2014 06:08:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XGmWL-0005D2-4q for qemu-devel@nongnu.org; Mon, 11 Aug 2014 06:08:14 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:57082) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XGmWK-0005Ch-VC for qemu-devel@nongnu.org; Mon, 11 Aug 2014 06:08:05 -0400 Received: from mail-vc0-f178.google.com ([209.85.220.178]) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1XGmWJ-00066h-Qr for qemu-devel@nongnu.org; Mon, 11 Aug 2014 10:08:03 +0000 Received: by mail-vc0-f178.google.com with SMTP id la4so11200972vcb.23 for ; Mon, 11 Aug 2014 03:08:02 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <1407317621-30591-1-git-send-email-pbonzini@redhat.com> References: <1407317621-30591-1-git-send-email-pbonzini@redhat.com> Date: Mon, 11 Aug 2014 18:08:02 +0800 Message-ID: From: Ming Lei Content-Type: text/plain; charset=UTF-8 Subject: Re: [Qemu-devel] [PATCH] test-coroutine: add baseline test that times the cost of function calls List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Kevin Wolf , qemu-devel , Stefan Hajnoczi On Wed, Aug 6, 2014 at 5:33 PM, Paolo Bonzini wrote: > This can be used to compute the cost of coroutine operations. In the > end the cost of the function call is a few clock cycles, so it's pretty > cheap for now, but it may become more relevant as the coroutine code > is optimized. > > For example, here are the results on my machine: > > Function call 100000000 iterations: 0.173884 s > Yield 100000000 iterations: 8.445064 s > Lifecycle 1000000 iterations: 0.098445 s > Nesting 10000 iterations of 1000 depth each: 7.406431 s > > One yield takes 83 nanoseconds, one enter takes 97 nanoseconds, > one coroutine allocation takes (roughly, since some of the allocations > in the nesting test do hit the pool) 739 nanoseconds: > > (8.445064 - 0.173884) * 10^9 / 100000000 = 82.7 > (0.098445 * 100 - 0.173884) * 10^9 / 100000000 = 96.7 > (7.406431 * 10 - 0.173884) * 10^9 / 100000000 = 738.9 Thought about it further, the above is _not_ cheap if it is computed correctly, take block layer for example: - suppose one block device can reach 300K IOPS, like Kevin's loop over tmpfs file, so handling one IO takes 3.333us - for handling one IO, at least two enter and one yield are required in current implementation, so these three operations take 0.277us(0.083 + 0.097 * 2) for handling one IO(suppose all allocations hit the pool) - so coroutine-only operations take 8.31%(0.277/3.333), not mention effect from switching stack Some modern storage devices can handle millions of IOPS, so using coroutine surely will slow down these devices a lot. Thanks,