From: "Benoît Canet" <benoit.canet@irqsave.net>
To: Ming Lei <ming.lei@canonical.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>,
qemu-devel@nongnu.org, Charlie Shepherd <charlie@ctshepherd.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Gabriel Kerneis <gabriel@kerneis.info>
Subject: Re: [Qemu-devel] [PATCH v1] test-coroutine: test cost introduced by coroutine
Date: Wed, 13 Aug 2014 16:27:29 +0200 [thread overview]
Message-ID: <20140813142729.GB3091@irqsave.net> (raw)
In-Reply-To: <1407924527-32687-1-git-send-email-ming.lei@canonical.com>
The Wednesday 13 Aug 2014 à 18:08:47 (+0800), Ming Lei wrote :
> This test runs dummy function with coroutine by using
> two enter and one yield since which is a common usage.
>
> So we can see the cost introduced by corouting for running
> one function, for example:
>
> Run operation 20000000 iterations 4.841071 s, 4131K operations/s
> 242ns per coroutine
>
> Signed-off-by: Ming Lei <ming.lei@canonical.com>
> ---
> tests/test-coroutine.c | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
> diff --git a/tests/test-coroutine.c b/tests/test-coroutine.c
> index 6e634f4..e22fae1 100644
> --- a/tests/test-coroutine.c
> +++ b/tests/test-coroutine.c
> @@ -311,6 +311,35 @@ static void perf_baseline(void)
> maxcycles, duration);
> }
>
> +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);
I am not sure qemu_coroutine_create is systematically used.
I rather believe the code try to reuse existing coroutine.
> + 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);
> +}
> +
> int main(int argc, char **argv)
> {
> g_test_init(&argc, &argv, NULL);
> @@ -325,6 +354,7 @@ int main(int argc, char **argv)
> g_test_add_func("/perf/nesting", perf_nesting);
> g_test_add_func("/perf/yield", perf_yield);
> g_test_add_func("/perf/function-call", perf_baseline);
> + g_test_add_func("/perf/cost", perf_cost);
> }
> return g_test_run();
> }
> --
> 1.7.9.5
>
>
next prev parent reply other threads:[~2014-08-13 14:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-13 10:08 [Qemu-devel] [PATCH v1] test-coroutine: test cost introduced by coroutine Ming Lei
2014-08-13 14:27 ` Benoît Canet [this message]
2014-08-13 14:31 ` Gabriel Kerneis
2014-08-14 0:41 ` Ming Lei
2014-08-19 13:57 ` Ming Lei
2014-08-19 14:13 ` Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140813142729.GB3091@irqsave.net \
--to=benoit.canet@irqsave.net \
--cc=charlie@ctshepherd.com \
--cc=gabriel@kerneis.info \
--cc=kwolf@redhat.com \
--cc=ming.lei@canonical.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).