All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/3] Performance improvements for xen_disk v2
@ 2018-11-02 10:00 Tim Smith
  2018-11-02 10:00 ` [PATCH 1/3] Improve xen_disk batching behaviour Tim Smith
                   ` (7 more replies)
  0 siblings, 8 replies; 52+ messages in thread
From: Tim Smith @ 2018-11-02 10:00 UTC (permalink / raw)
  To: xen-devel, qemu-devel, qemu-block
  Cc: Anthony Perard, Kevin Wolf, Paul Durrant, Stefano Stabellini, Max Reitz

A series of performance improvements for disks using the Xen PV ring.

These have had fairly extensive testing.

The batching and latency improvements together boost the throughput
of small reads and writes by two to six percent (measured using fio
in the guest)

Avoiding repeated calls to posix_memalign() reduced the dirty heap
from 25MB to 5MB in the case of a single datapath process while also
improving performance.

v2 removes some checkpatch complaints and fixes the CCs

---

Tim Smith (3):
      Improve xen_disk batching behaviour
      Improve xen_disk response latency
      Avoid repeated memory allocation in xen_disk


 hw/block/xen_disk.c |   82 +++++++++++++++++++++++++++++----------------------
 1 file changed, 46 insertions(+), 36 deletions(-)

--
Tim Smith <tim.smith@citrix.com>

^ permalink raw reply	[flat|nested] 52+ messages in thread
* [Qemu-devel] [PATCH 0/3] Performance improvements for xen_disk
@ 2018-11-02  9:29 Tim Smith
  2018-11-02  9:29 ` [Qemu-devel] [PATCH 1/3] Improve xen_disk batching behaviour Tim Smith
  0 siblings, 1 reply; 52+ messages in thread
From: Tim Smith @ 2018-11-02  9:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul Durrant

A series of performance improvements for disks using the Xen PV ring.

These have had fairly extensive testing.

The batching and latency improvements together boost the throughput
of small reads and writes by two to six percent (measured using fio
in the guest)

Avoiding repeated calls to posix_memalign() reduced the dirty heap
from 25MB to 5MB in the case of a single datapath process while also
improving performance.

---

Tim Smith (3):
      Improve xen_disk batching behaviour
      Improve xen_disk response latency
      Avoid repeated memory allocation in xen_disk


 hw/block/xen_disk.c |   82 +++++++++++++++++++++++++++++----------------------
 1 file changed, 46 insertions(+), 36 deletions(-)

--
Tim Smith <tim.smith@citrix.com>

^ permalink raw reply	[flat|nested] 52+ messages in thread
* [Qemu-devel] [PATCH 1/3] Improve xen_disk batching behaviour
@ 2018-09-07 10:21 Tim Smith
  2018-09-07 14:11 ` Paul Durrant
  0 siblings, 1 reply; 52+ messages in thread
From: Tim Smith @ 2018-09-07 10:21 UTC (permalink / raw)
  To: qemu-devel

When I/O consists of many small requests, performance is improved by
batching them together in a single io_submit() call. When there are
relatively few requests, the extra overhead is not worth it. This
introduces a check to start batching I/O requests via blk_io_plug()/
blk_io_unplug() in an amount proportional to the number which were
already in flight at the time we started reading the ring.

Signed-off-by: Tim Smith <tim.smith@citrix.com>
---
 hw/block/xen_disk.c |   29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
index 36eff94f84..6cb40d66fa 100644
--- a/hw/block/xen_disk.c
+++ b/hw/block/xen_disk.c
@@ -101,6 +101,9 @@ struct XenBlkDev {
     AioContext          *ctx;
 };
 
+/* Threshold of in-flight requests above which we will start using
+ * blk_io_plug()/blk_io_unplug() to batch requests */
+#define IO_PLUG_THRESHOLD 1
 /* ------------------------------------------------------------- */
 
 static void ioreq_reset(struct ioreq *ioreq)
@@ -542,6 +545,8 @@ static void blk_handle_requests(struct XenBlkDev *blkdev)
 {
     RING_IDX rc, rp;
     struct ioreq *ioreq;
+    int inflight_atstart = blkdev->requests_inflight;
+    int batched = 0;
 
     blkdev->more_work = 0;
 
@@ -550,6 +555,16 @@ static void blk_handle_requests(struct XenBlkDev *blkdev)
     xen_rmb(); /* Ensure we see queued requests up to 'rp'. */
 
     blk_send_response_all(blkdev);
+    /* If there was more than IO_PLUG_THRESHOLD ioreqs in flight
+     * when we got here, this is an indication that there the bottleneck
+     * is below us, so it's worth beginning to batch up I/O requests
+     * rather than submitting them immediately. The maximum number
+     * of requests we're willing to batch is the number already in
+     * flight, so it can grow up to max_requests when the bottleneck
+     * is below us */
+    if (inflight_atstart > IO_PLUG_THRESHOLD) {
+        blk_io_plug(blkdev->blk);
+    }
     while (rc != rp) {
         /* pull request from ring */
         if (RING_REQUEST_CONS_OVERFLOW(&blkdev->rings.common, rc)) {
@@ -589,7 +604,21 @@ static void blk_handle_requests(struct XenBlkDev *blkdev)
             continue;
         }
 
+        if (inflight_atstart > IO_PLUG_THRESHOLD && batched >= inflight_atstart) {
+            blk_io_unplug(blkdev->blk);
+        }
         ioreq_runio_qemu_aio(ioreq);
+        if (inflight_atstart > IO_PLUG_THRESHOLD) {
+            if (batched >= inflight_atstart) {
+                blk_io_plug(blkdev->blk);
+                batched=0;
+            } else {
+                batched++;
+            }
+        }
+    }
+    if (inflight_atstart > IO_PLUG_THRESHOLD) {
+        blk_io_unplug(blkdev->blk);
     }
 
     if (blkdev->more_work && blkdev->requests_inflight < blkdev->max_requests) {

^ permalink raw reply related	[flat|nested] 52+ messages in thread

end of thread, other threads:[~2018-12-12 12:04 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-02 10:00 [Qemu-devel] [PATCH 0/3] Performance improvements for xen_disk v2 Tim Smith
2018-11-02 10:00 ` [PATCH 1/3] Improve xen_disk batching behaviour Tim Smith
2018-11-02 10:00 ` [Qemu-devel] " Tim Smith
2018-11-02 11:14   ` Paul Durrant
2018-11-02 11:14   ` Paul Durrant
2018-11-02 13:53   ` Anthony PERARD
2018-11-02 13:53   ` [Qemu-devel] " Anthony PERARD
2018-11-02 10:01 ` [Qemu-devel] [PATCH 2/3] Improve xen_disk response latency Tim Smith
2018-11-02 11:14   ` Paul Durrant
2018-11-02 11:14     ` Paul Durrant
2018-11-02 13:53   ` Anthony PERARD
2018-11-02 13:53   ` [Qemu-devel] " Anthony PERARD
2018-11-02 10:01 ` Tim Smith
2018-11-02 10:01 ` [PATCH 3/3] Avoid repeated memory allocation in xen_disk Tim Smith
2018-11-02 10:01 ` [Qemu-devel] " Tim Smith
2018-11-02 11:15   ` Paul Durrant
2018-11-02 11:15     ` Paul Durrant
2018-11-02 13:53   ` [Qemu-devel] " Anthony PERARD
2018-11-02 13:53     ` Anthony PERARD
2018-11-02 11:04 ` xen_disk qdevification (was: [PATCH 0/3] Performance improvements for xen_disk v2) Kevin Wolf
2018-11-02 11:04 ` [Qemu-devel] " Kevin Wolf
2018-11-02 11:13   ` Paul Durrant
2018-11-02 11:13   ` [Qemu-devel] " Paul Durrant
2018-11-02 12:14     ` Kevin Wolf
2018-11-02 12:14     ` [Qemu-devel] " Kevin Wolf
2018-11-05 15:57     ` [Qemu-devel] xen_disk qdevification Markus Armbruster
2018-11-05 15:57       ` Markus Armbruster
2018-11-05 16:15       ` Paul Durrant
2018-11-05 16:15         ` Paul Durrant
2018-11-08 14:00       ` Paul Durrant
2018-11-08 14:00       ` Paul Durrant
2018-11-08 15:21         ` Kevin Wolf
2018-11-08 15:43           ` Paul Durrant
2018-11-08 15:43           ` Paul Durrant
2018-11-08 16:44             ` Paul Durrant
2018-11-09 10:27               ` Paul Durrant
2018-11-09 10:40                 ` Kevin Wolf
2018-11-09 10:40                 ` Kevin Wolf
2018-11-09 10:27               ` Paul Durrant
2018-11-08 16:44             ` Paul Durrant
2018-11-08 15:21         ` Kevin Wolf
2018-12-12  8:59   ` [Qemu-devel] [Xen-devel] xen_disk qdevification (was: [PATCH 0/3] Performance improvements for xen_disk v2) Olaf Hering
2018-12-12  9:22     ` Paul Durrant
2018-12-12  9:22       ` Paul Durrant
2018-12-12 12:03     ` [Qemu-devel] [Xen-devel] " Kevin Wolf
2018-12-12 12:03     ` Kevin Wolf
2018-12-12 12:04     ` [Qemu-devel] xen_disk qdevification Markus Armbruster
2018-12-12 12:04     ` [Qemu-devel] [Xen-devel] " Markus Armbruster
2018-12-12  8:59   ` xen_disk qdevification (was: [PATCH 0/3] Performance improvements for xen_disk v2) Olaf Hering
  -- strict thread matches above, loose matches on Subject: below --
2018-11-02  9:29 [Qemu-devel] [PATCH 0/3] Performance improvements for xen_disk Tim Smith
2018-11-02  9:29 ` [Qemu-devel] [PATCH 1/3] Improve xen_disk batching behaviour Tim Smith
2018-09-07 10:21 Tim Smith
2018-09-07 14:11 ` Paul Durrant

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.