Received: from eggs.gnu.org ([2001:4830:134:3::10]:55796) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XuHOd-0001cn-9r for qemu-devel@nongnu.org; Fri, 28 Nov 2014 03:59:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XuHOY-0004Cm-7s for qemu-devel@nongnu.org; Fri, 28 Nov 2014 03:59:23 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56391) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XuHOX-0004Ch-VA for qemu-devel@nongnu.org; Fri, 28 Nov 2014 03:59:18 -0500 From: Markus Armbruster References: <1417013204-30676-1-git-send-email-kwolf@redhat.com> <1417013204-30676-3-git-send-email-kwolf@redhat.com> <87h9xj93v5.fsf@blackfin.pond.sub.org> Date: Fri, 28 Nov 2014 09:59:00 +0100 In-Reply-To: (Ming Lei's message of "Fri, 28 Nov 2014 16:12:55 +0800") Message-ID: <87iohz66qz.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [RFC PATCH 2/3] raw-posix: Convert Linux AIO submission to coroutines List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ming Lei Cc: Kevin Wolf , Paolo Bonzini , pl@kamp.de, qemu-devel , Stefan Hajnoczi Ming Lei writes: > On 11/28/14, Markus Armbruster wrote: >> Ming Lei writes: >> >>> Hi Kevin, >>> >>> On Wed, Nov 26, 2014 at 10:46 PM, Kevin Wolf wrote: >>>> This improves the performance of requests because an ACB doesn't need to >>>> be allocated on the heap any more. It also makes the code nicer and >>>> smaller. >>> >>> I am not sure it is good way for linux aio optimization: >>> >>> - for raw image with some constraint, coroutine can be avoided since >>> io_submit() won't sleep most of times >>> >>> - handling one time coroutine takes much time than handling malloc, >>> memset and free on small buffer, following the test data: >>> >>> -- 241ns per coroutine >> >> What do you mean by "coroutine" here? Create + destroy? Yield? > > Please see perf_cost() in tests/test-coroutine.c static __attribute__((noinline)) void perf_cost_func(void *opaque) { qemu_coroutine_yield(); } static void perf_cost(void) { const unsigned long maxcycles = 40000000; unsigned long i = 0; double duration; unsigned long ops; Coroutine *co; g_test_timer_start(); while (i++ < maxcycles) { co = qemu_coroutine_create(perf_cost_func); qemu_coroutine_enter(co, &i); qemu_coroutine_enter(co, NULL); } duration = g_test_timer_elapsed(); ops = (long)(maxcycles / (duration * 1000)); g_test_message("Run operation %lu iterations %f s, %luK operations/s, " "%luns per coroutine", maxcycles, duration, ops, (unsigned long)(1000000000 * duration) / maxcycles); } This tests create, enter, yield, reenter, terminate, destroy. The cost of create + destroy may well dominate. If we create and destroy coroutines for each AIO request, we're doing it wrong. I doubt Kevin's doing it *that* wrong ;) Anyway, let's benchmark the real code instead of putting undue trust in tests/test-coroutine.c micro-benchmarks.