From: Stefan Hajnoczi <stefanha@redhat.com>
To: Fam Zheng <famz@redhat.com>
Cc: qemu-devel@nongnu.org, borntraeger@de.ibm.com,
Paolo Bonzini <pbonzini@redhat.com>,
Karl Rister <krister@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v4 00/13] aio: experimental virtio-blk polling mode
Date: Mon, 5 Dec 2016 14:56:26 +0000 [thread overview]
Message-ID: <20161205145626.GF30434@stefanha-x1.localdomain> (raw)
In-Reply-To: <20161205102549.GA23432@lemon>
[-- Attachment #1: Type: text/plain, Size: 3825 bytes --]
On Mon, Dec 05, 2016 at 06:25:49PM +0800, Fam Zheng wrote:
> On Thu, 12/01 19:26, Stefan Hajnoczi wrote:
> > One way to avoid the costly exit is to use polling instead of notification.
>
> Testing with fio on virtio-blk backed by NVMe device, I can see significant
> performance improvement with this series:
>
> poll-max-ns iodepth=1 iodepth=32
> --------------------------------------
> 0 24806.94 151430.36
> 1 24435.02 155285.59
> 100 24702.41 149937.2
> 1000 24457.08 152936.3
> 10000 24605.05 156158.12
> 13000 24412.95 154908.73
> 16000 30654.24 185731.58
> 18000 36365.69 185538.78
> 20000 35640.48 188640.61
> 30000 37411.05 184198.39
> 60000 35230.66 190427.42
>
> So this definitely helps synchronous I/O with queue depth = 1. Great!
Nice. Even with iodepth=32 the improvement is significant.
> I have a small concern with high queue depth, though. The more frequent we check
> the virtqueue, the less likely the requests can be batched, and the more
> submissions (both from guest to QEMU and from QEMU to host) are needed to
> achieve the same bandwidth, because we'd do less plug/unplug. This could be a
> problem under heavy workload. We may want to consider the driver's transient
> state when it is appending requests to the virtqueue. For example, virtio-blk
> driver in Linux updates avail idx after adding each request. If QEMU looks at
> the index in the middle, it will miss the opportunities to plug/unplug and merge
> requests. On the other hand, though virtio-blk driver doesn't have IO scheduler,
> it does have some batch submission semantics passed down by blk-mq (see the
> "notify" condition in drivers/block/virtio_blk.c:virtio_queue_rq()). So I'm
> wondering whether it makes sense to wait for the whole batch of requests to be
> added to the virtqueue before processing it? This can be done by changing the
> driver to only update "avail" index after all requests are added to the queue,
> or even adding a flag in the virtio ring descriptor to suppress busy polling.
Only benchmarking can tell. It would be interesting to extract the
vq->vring.avail->idx update from virtqueue_add(). I don't think a new
flag is necessary.
> > The main drawback of polling is that it consumes CPU resources. In order to
> > benefit performance the host must have extra CPU cycles available on physical
> > CPUs that aren't used by the guest.
> >
> > This is an experimental AioContext polling implementation. It adds a polling
> > callback into the event loop. Polling functions are implemented for virtio-blk
> > virtqueue guest->host kick and Linux AIO completion.
> >
> > The -object iothread,poll-max-ns=NUM parameter sets the number of nanoseconds
> > to poll before entering the usual blocking poll(2) syscall. Try setting this
> > parameter to the time from old request completion to new virtqueue kick. By
> > default no polling is done so you must set this parameter to get busy polling.
>
> Given the self tuning, should we document the best practice in setting the
> value? Is it okay for user or even QEMU to use a relatively large value by
> default and expect it to tune itself sensibly?
Karl: do you have time to run a bigger suite of benchmarks to identify a
reasonable default poll-max-ns value? Both aio=native and aio=threads
are important.
If there is a sweet spot that improves performance without pathological
cases then we could even enable polling by default in QEMU.
Otherwise we'd just document the recommended best polling duration as a
starting point for users.
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
next prev parent reply other threads:[~2016-12-05 14:56 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-01 19:26 [Qemu-devel] [PATCH v4 00/13] aio: experimental virtio-blk polling mode Stefan Hajnoczi
2016-12-01 19:26 ` [Qemu-devel] [PATCH v4 01/13] aio: add flag to skip fds to aio_dispatch() Stefan Hajnoczi
2016-12-01 19:26 ` [Qemu-devel] [PATCH v4 02/13] aio: add AioPollFn and io_poll() interface Stefan Hajnoczi
2016-12-01 19:26 ` [Qemu-devel] [PATCH v4 03/13] aio: add polling mode to AioContext Stefan Hajnoczi
2016-12-01 19:26 ` [Qemu-devel] [PATCH v4 04/13] virtio: poll virtqueues for new buffers Stefan Hajnoczi
2016-12-05 0:54 ` Fam Zheng
2016-12-05 10:14 ` Stefan Hajnoczi
2016-12-05 10:59 ` Paolo Bonzini
2016-12-05 14:46 ` Stefan Hajnoczi
2016-12-05 15:22 ` Paolo Bonzini
2016-12-06 9:28 ` Stefan Hajnoczi
2016-12-05 11:12 ` Christian Borntraeger
2016-12-01 19:26 ` [Qemu-devel] [PATCH v4 05/13] linux-aio: poll ring for completions Stefan Hajnoczi
2016-12-01 19:26 ` [Qemu-devel] [PATCH v4 06/13] iothread: add polling parameters Stefan Hajnoczi
2016-12-01 19:26 ` [Qemu-devel] [PATCH v4 07/13] virtio-blk: suppress virtqueue kick during processing Stefan Hajnoczi
2016-12-01 19:26 ` [Qemu-devel] [PATCH v4 08/13] virtio-scsi: " Stefan Hajnoczi
2016-12-01 19:26 ` [Qemu-devel] [PATCH v4 09/13] virtio: turn vq->notification into a nested counter Stefan Hajnoczi
2016-12-01 19:26 ` [Qemu-devel] [PATCH v4 10/13] aio: add .io_poll_begin/end() callbacks Stefan Hajnoczi
2016-12-01 19:26 ` [Qemu-devel] [PATCH v4 11/13] virtio: disable virtqueue notifications during polling Stefan Hajnoczi
2016-12-01 19:26 ` [Qemu-devel] [PATCH v4 12/13] aio: self-tune polling time Stefan Hajnoczi
2016-12-05 20:06 ` Christian Borntraeger
2016-12-06 9:20 ` Stefan Hajnoczi
2016-12-06 10:12 ` Christian Borntraeger
2016-12-06 17:22 ` Stefan Hajnoczi
2016-12-01 19:26 ` [Qemu-devel] [PATCH v4 13/13] iothread: add poll-grow and poll-shrink parameters Stefan Hajnoczi
2016-12-02 8:27 ` [Qemu-devel] [PATCH v4 00/13] aio: experimental virtio-blk polling mode Paolo Bonzini
2016-12-02 11:11 ` Stefan Hajnoczi
2016-12-05 10:25 ` Fam Zheng
2016-12-05 14:56 ` Stefan Hajnoczi [this message]
2016-12-05 16:40 ` Karl Rister
2016-12-06 9:27 ` Stefan Hajnoczi
2016-12-05 11:19 ` Christian Borntraeger
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=20161205145626.GF30434@stefanha-x1.localdomain \
--to=stefanha@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=famz@redhat.com \
--cc=krister@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).