qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] qcow2: seriously improve savevm performance
@ 2020-06-10 14:41 Denis V. Lunev
  2020-06-10 14:41 ` [PATCH 1/2] aio: allow to wait for coroutine pool from different coroutine Denis V. Lunev
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Denis V. Lunev @ 2020-06-10 14:41 UTC (permalink / raw)
  To: qemu-block, qemu-devel
  Cc: Kevin Wolf, Denis V . Lunev, Vladimir Sementsov-Ogievskiy,
	Denis Plotnikov, Max Reitz

This series do standard basic things:
- it creates intermediate buffer for all writes from QEMU migration code
  to QCOW2 image,
- this buffer is sent to disk asynchronously, allowing several writes to
  run in parallel.

In general, migration code is fantastically inefficent (by observation),
buffers are not aligned and sent with arbitrary pieces, a lot of time
less than 100 bytes at a chunk, which results in read-modify-write
operations with non-cached operations. It should also be noted that all
operations are performed into unallocated image blocks, which also suffer
due to partial writes to such new clusters.

This patch series is an implementation of idea discussed in the RFC
posted by Denis
https://lists.gnu.org/archive/html/qemu-devel/2020-04/msg01925.html
Results with this series over NVME are better than original code
                original     rfc    this
cached:          1.79s      2.38s   1.27s
non-cached:      3.29s      1.31s   0.81s

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Max Reitz <mreitz@redhat.com>
CC: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
CC: Denis Plotnikov <dplotnikov@virtuozzo.com>



^ permalink raw reply	[flat|nested] 10+ messages in thread
* [PATCH 1/2] aio: allow to wait for coroutine pool from different coroutine
@ 2020-06-10 18:58 Denis V. Lunev
  0 siblings, 0 replies; 10+ messages in thread
From: Denis V. Lunev @ 2020-06-10 18:58 UTC (permalink / raw)
  To: qemu-block, qemu-devel
  Cc: Kevin Wolf, Denis V. Lunev, Vladimir Sementsov-Ogievskiy,
	Denis Plotnikov, Max Reitz

The patch preserves the constraint that the only waiter is allowed.

The patch renames AioTaskPool->main_co to wake_co and removes
AioTaskPool->waiting flag. wake_co keeps coroutine, which is
waiting for wakeup on worker completion. Thus 'waiting' flag
in this semantics is equivalent to 'wake_co != NULL'.

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Max Reitz <mreitz@redhat.com>
CC: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
CC: Denis Plotnikov <dplotnikov@virtuozzo.com>
---
 block/aio_task.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/block/aio_task.c b/block/aio_task.c
index 88989fa248..5183b0729d 100644
--- a/block/aio_task.c
+++ b/block/aio_task.c
@@ -27,11 +27,10 @@
 #include "block/aio_task.h"
 
 struct AioTaskPool {
-    Coroutine *main_co;
+    Coroutine *wake_co;
     int status;
     int max_busy_tasks;
     int busy_tasks;
-    bool waiting;
 };
 
 static void coroutine_fn aio_task_co(void *opaque)
@@ -52,21 +51,21 @@ static void coroutine_fn aio_task_co(void *opaque)
 
     g_free(task);
 
-    if (pool->waiting) {
-        pool->waiting = false;
-        aio_co_wake(pool->main_co);
+    if (pool->wake_co != NULL) {
+        aio_co_wake(pool->wake_co);
+        pool->wake_co = NULL;
     }
 }
 
 void coroutine_fn aio_task_pool_wait_one(AioTaskPool *pool)
 {
     assert(pool->busy_tasks > 0);
-    assert(qemu_coroutine_self() == pool->main_co);
+    assert(pool->wake_co == NULL);
 
-    pool->waiting = true;
+    pool->wake_co = qemu_coroutine_self();
     qemu_coroutine_yield();
 
-    assert(!pool->waiting);
+    assert(pool->wake_co == NULL);
     assert(pool->busy_tasks < pool->max_busy_tasks);
 }
 
@@ -98,7 +97,7 @@ AioTaskPool *coroutine_fn aio_task_pool_new(int max_busy_tasks)
 {
     AioTaskPool *pool = g_new0(AioTaskPool, 1);
 
-    pool->main_co = qemu_coroutine_self();
+    pool->wake_co = NULL;
     pool->max_busy_tasks = max_busy_tasks;
 
     return pool;
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread
* [PATCH v2 0/2] qcow2: seriously improve savevm performance
@ 2020-06-10 19:00 Denis V. Lunev
  2020-06-10 19:00 ` [PATCH 1/2] aio: allow to wait for coroutine pool from different coroutine Denis V. Lunev
  0 siblings, 1 reply; 10+ messages in thread
From: Denis V. Lunev @ 2020-06-10 19:00 UTC (permalink / raw)
  To: qemu-block, qemu-devel
  Cc: Kevin Wolf, Denis V . Lunev, Vladimir Sementsov-Ogievskiy,
	Denis Plotnikov, Max Reitz

This series do standard basic things:
- it creates intermediate buffer for all writes from QEMU migration code
  to QCOW2 image,
- this buffer is sent to disk asynchronously, allowing several writes to
  run in parallel.

In general, migration code is fantastically inefficent (by observation),
buffers are not aligned and sent with arbitrary pieces, a lot of time
less than 100 bytes at a chunk, which results in read-modify-write
operations with non-cached operations. It should also be noted that all
operations are performed into unallocated image blocks, which also suffer
due to partial writes to such new clusters.

This patch series is an implementation of idea discussed in the RFC
posted by Denis
https://lists.gnu.org/archive/html/qemu-devel/2020-04/msg01925.html
Results with this series over NVME are better than original code
                original     rfc    this
cached:          1.79s      2.38s   1.27s
non-cached:      3.29s      1.31s   0.81s

Changes from v1:
- patchew warning fixed
- fixed validation that only 1 waiter is allowed in patch 1

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Max Reitz <mreitz@redhat.com>
CC: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
CC: Denis Plotnikov <dplotnikov@virtuozzo.com>



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

end of thread, other threads:[~2020-06-10 19:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-10 14:41 [PATCH 0/2] qcow2: seriously improve savevm performance Denis V. Lunev
2020-06-10 14:41 ` [PATCH 1/2] aio: allow to wait for coroutine pool from different coroutine Denis V. Lunev
2020-06-10 15:10   ` Vladimir Sementsov-Ogievskiy
2020-06-10 16:52     ` Denis V. Lunev
2020-06-10 14:41 ` [PATCH 2/2] qcow2: improve savevm performance Denis V. Lunev
2020-06-10 18:19 ` [PATCH 0/2] qcow2: seriously " no-reply
2020-06-10 18:24 ` no-reply
2020-06-10 18:24 ` no-reply
  -- strict thread matches above, loose matches on Subject: below --
2020-06-10 18:58 [PATCH 1/2] aio: allow to wait for coroutine pool from different coroutine Denis V. Lunev
2020-06-10 19:00 [PATCH v2 0/2] qcow2: seriously improve savevm performance Denis V. Lunev
2020-06-10 19:00 ` [PATCH 1/2] aio: allow to wait for coroutine pool from different coroutine Denis V. Lunev

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).