From: Peter Lieven <pl@kamp.de>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, ming.lei@canonical.com, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH 7/7] coroutine: try harder not to delete coroutines
Date: Fri, 28 Nov 2014 21:52:53 +0100 [thread overview]
Message-ID: <5478E0A5.6060405@kamp.de> (raw)
In-Reply-To: <1417183941-26329-8-git-send-email-pbonzini@redhat.com>
Am 28.11.2014 um 15:12 schrieb Paolo Bonzini:
> From: Peter Lieven <pl@kamp.de>
>
> Placing coroutines on the global pool should be preferrable, because it
> can help all threads. But if the global pool is full, we can still
> try to save some allocations by stashing completed coroutines on the
> local pool. This is quite cheap too, because it does not require
> atomic operations.
At least in test-couroutine.c this turns out to be not just a nice to have.
I have not fully understood why, but i get the following results:
master:
Run operation 40000000 iterations 13.612604 s, 2938K operations/s, 340ns per coroutine
this series up to patch 6:
Run operation 40000000 iterations 10.428382 s, 3835K operations/s, 260ns per coroutine
this series up to patch 7:
Run operation 40000000 iterations 9.112539 s, 4389K operations/s, 227ns per coroutine
So this confirms the +33% Paolo sees up to Patch 5. But I have yet fully understood the
+15% that this Patch gains.
>
> Signed-off-by: Peter Lieven <pl@kamp.de>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> qemu-coroutine.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/qemu-coroutine.c b/qemu-coroutine.c
> index da1b961..977f114 100644
> --- a/qemu-coroutine.c
> +++ b/qemu-coroutine.c
> @@ -27,6 +27,7 @@ enum {
> static QSLIST_HEAD(, Coroutine) release_pool = QSLIST_HEAD_INITIALIZER(pool);
> static unsigned int release_pool_size;
> static __thread QSLIST_HEAD(, Coroutine) alloc_pool = QSLIST_HEAD_INITIALIZER(pool);
> +static __thread unsigned int alloc_pool_size;
> static __thread Notifier coroutine_pool_cleanup_notifier;
>
> static void coroutine_pool_cleanup(Notifier *n, void *value)
> @@ -58,13 +59,14 @@ Coroutine *qemu_coroutine_create(CoroutineEntry *entry)
> * release_pool_size and the actual size of release_pool. But
> * it is just a heuristic, it does not need to be perfect.
> */
> - release_pool_size = 0;
> + alloc_pool_size += atomic_xchg(&release_pool_size, 0);
I had alloc_pool_size = in my original Patch.
It shouldn't make a difference, since alloc_pool_size should be 0
when we reach this code piece. But if for some reason release_pool_size
is inaccurate we add this error to alloc_pool_size again and again
and eventually end up not adding coroutines to the thread local pool below
altough it might be empty in the worst case.
Peter
next prev parent reply other threads:[~2014-11-28 20:53 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-28 14:12 [Qemu-devel] [PATCH 0/7] coroutine: optimizations Paolo Bonzini
2014-11-28 14:12 ` [Qemu-devel] [PATCH 1/7] coroutine-ucontext: use __thread Paolo Bonzini
2014-11-28 14:28 ` Peter Maydell
2014-11-28 14:45 ` Markus Armbruster
2014-11-28 15:36 ` Kevin Wolf
2014-11-28 14:12 ` [Qemu-devel] [PATCH 2/7] qemu-thread: add per-thread atexit functions Paolo Bonzini
2014-11-28 14:12 ` [Qemu-devel] [PATCH 3/7] test-coroutine: avoid overflow on 32-bit systems Paolo Bonzini
2014-12-01 1:28 ` Ming Lei
2014-12-01 12:41 ` Paolo Bonzini
2014-12-02 1:20 ` Ming Lei
2014-11-28 14:12 ` [Qemu-devel] [PATCH 4/7] QSLIST: add lock-free operations Paolo Bonzini
2014-11-28 14:12 ` [Qemu-devel] [PATCH 5/7] coroutine: rewrite pool to avoid mutex Paolo Bonzini
2014-11-28 16:40 ` Kevin Wolf
2014-11-28 17:30 ` Paolo Bonzini
2014-11-28 17:31 ` Paolo Bonzini
2014-11-28 18:34 ` Kevin Wolf
2014-11-28 19:57 ` Paolo Bonzini
2014-11-28 14:12 ` [Qemu-devel] [PATCH 6/7] coroutine: drop qemu_coroutine_adjust_pool_size Paolo Bonzini
2014-11-28 14:12 ` [Qemu-devel] [PATCH 7/7] coroutine: try harder not to delete coroutines Paolo Bonzini
2014-11-28 20:52 ` Peter Lieven [this message]
2014-11-29 14:27 ` Paolo Bonzini
2014-11-29 21:28 ` Peter Lieven
2014-11-29 14:28 ` Paolo Bonzini
2014-12-01 5:55 ` [Qemu-devel] [PATCH 0/7] coroutine: optimizations Ming Lei
2014-12-01 7:05 ` Peter Lieven
2014-12-01 7:46 ` Ming Lei
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=5478E0A5.6060405@kamp.de \
--to=pl@kamp.de \
--cc=kwolf@redhat.com \
--cc=ming.lei@canonical.com \
--cc=pbonzini@redhat.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.