From: Stefan Hajnoczi <stefanha@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>, Fam Zheng <famz@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Ming Lei <tom.leiming@gmail.com>,
qemu-devel <qemu-devel@nongnu.org>,
Stefan Hajnoczi <stefanha@gmail.com>
Subject: Re: [Qemu-devel] [regression] dataplane: throughout -40% by commit 580b6b2aa2
Date: Wed, 2 Jul 2014 10:54:53 +0200 [thread overview]
Message-ID: <20140702085453.GI4660@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <53B2E69A.1090707@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2720 bytes --]
On Tue, Jul 01, 2014 at 06:49:30PM +0200, Paolo Bonzini wrote:
> Il 01/07/2014 16:49, Ming Lei ha scritto:
> >Let me provide some data when running randread(bs 4k, libaio)
> >from VM for 10sec:
> >
> >1), qemu.git/master
> >- write(): 731K
> >- rt_sigprocmask(): 417K
> >- read(): 21K
> >- ppoll(): 10K
> >- io_submit(): 5K
> >- io_getevents(): 4K
> >
> >2), qemu 2.0
> >- write(): 9K
> >- read(): 28K
> >- ppoll(): 16K
> >- io_submit(): 12K
> >- io_getevents(): 10K
> >
> >>> The sigprocmask can probably be optimized away since the thread's
> >>> signal mask remains unchanged most of the time.
> >>>
> >>> I'm not sure what is causing the write().
> >I am investigating it...
>
> I would guess sigprocmask is getcontext (from qemu_coroutine_new) and write
> is aio_notify (from qemu_bh_schedule).
Aha! We shouldn't be executing qemu_coroutine_new() very often since we
try to keep a freelist of coroutines.
I think a tweak to the freelist could make the rt_sigprocmask() calls go
away since we should be reusing coroutines instead of allocating/freeing
them all the time.
> Both can be eliminated by introducing a fast path in bdrv_aio_{read,write}v,
> that bypasses coroutines in the common case of no I/O throttling, no
> copy-on-write, etc.
I tried that in 2012 and couldn't measure an improvement above the noise
threshold, although it was without dataplane.
BTW, we cannot eliminate the BH because the block layer guarantees that
callbacks are not invoked with reentrancy. They are always invoked
directly from the event loop through a BH. This simplifies callers
since they don't need to worry about callbacks happening while they are
still in bdrv_aio_readv(), for example.
Removing this guarantee (by making callers safe first) is orthogonal to
coroutines. But it's hard to do since it requires auditing a lot of
code.
Another idea is to skip aio_notify() when we're sure the event loop
isn't blocked in g_poll(). Doing this is a thread-safe and lockless way
might be tricky though.
So to recap, three issues are being discussed here:
1. rt_sigprocmask due to getcontext() in qemu_coroutine_new(). We
shouldn't be invoking qemu_coroutine_new() often. The freelist is
probably too small.
2. Coroutines might be slower than the non-coroutine aio codepath. I
don't think this is the case, they are very cheap and I was never able
to measure a real difference.
3. The block layer requires a BH with aio_notify() for
bdrv_aio_readv()/bdrv_aio_writev()/bdrv_aio_flush() callbacks regardless
of coroutines or not. Eliminating the BH or skipping aio_notify() will
take some work but could speed up QEMU as a whole.
Stefan
[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2014-07-02 8:55 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-26 15:14 [Qemu-devel] [regression] dataplane: throughout -40% by commit 580b6b2aa2 Ming Lei
2014-06-26 15:29 ` Paolo Bonzini
2014-06-26 15:37 ` Ming Lei
2014-06-26 15:43 ` Paolo Bonzini
2014-06-26 15:47 ` Ming Lei
2014-06-26 15:57 ` Paolo Bonzini
2014-06-27 1:15 ` Ming Lei
2014-06-27 4:59 ` Paolo Bonzini
2014-06-27 6:23 ` Kevin Wolf
2014-06-27 7:35 ` Paolo Bonzini
2014-06-27 12:35 ` Ming Lei
2014-06-27 7:57 ` Ming Lei
2014-06-27 12:01 ` Stefan Hajnoczi
2014-06-27 12:21 ` Kevin Wolf
2014-06-27 14:50 ` Stefan Hajnoczi
2014-06-27 18:01 ` Ming Lei
2014-06-27 21:51 ` Paolo Bonzini
2014-06-28 9:58 ` Ming Lei
2014-06-30 8:08 ` Stefan Hajnoczi
2014-06-30 8:27 ` Ming Lei
2014-07-01 13:53 ` Ming Lei
2014-07-01 14:31 ` Stefan Hajnoczi
2014-07-01 14:49 ` Ming Lei
2014-07-01 16:49 ` Paolo Bonzini
2014-07-02 0:48 ` Ming Lei
2014-07-02 8:54 ` Stefan Hajnoczi [this message]
2014-07-02 9:13 ` Paolo Bonzini
2014-07-02 9:39 ` Kevin Wolf
2014-07-02 9:48 ` Paolo Bonzini
2014-07-02 10:01 ` Kevin Wolf
2014-07-02 10:23 ` Paolo Bonzini
2014-07-02 15:45 ` Ming Lei
2014-07-02 16:13 ` Ming Lei
2014-07-02 16:23 ` Paolo Bonzini
2014-07-02 16:27 ` Ming Lei
2014-07-02 16:38 ` Paolo Bonzini
2014-07-02 16:41 ` Ming Lei
2014-07-02 16:21 ` Paolo Bonzini
2014-07-03 4:54 ` Ming Lei
2014-07-03 10:29 ` Paolo Bonzini
2014-07-03 11:50 ` Ming Lei
2014-07-03 11:56 ` Paolo Bonzini
2014-07-03 12:09 ` 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=20140702085453.GI4660@stefanha-thinkpad.redhat.com \
--to=stefanha@redhat.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
--cc=tom.leiming@gmail.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).