Skip to content

block: seriously improve savevm/loadvm performance

Denis V. Lunev qemu-devel 8 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v8 Latest6 patches 8 repliesIn review
  2. v77 patches 1 replySuperseded
  3. v67 patches 1 replySuperseded
Earlier versions · 5
VersionPostedPatchesRepliesStatus
v56 patches6 repliesSuperseded
v40 of 4 patches0 repliesSuperseded
v34 patches10 repliesSuperseded
v22 patches3 repliesSuperseded
v12 patches2 repliesSuperseded

Changes in v8 from the cover letter

- dropped lock from LoadVMState
- fixed assert in last patch
- dropped patch 1 as queued

Patches in v8 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6block/aio_task: allow start/wait task from any coroutineblock/aio_task.c+6 -150 replies
2/6block/aio_task: drop aio_task_pool_wait_one() helperblock/aio_task.c include/block/aio_task.h+2 -120 replies
3/6block/block-backend: remove always true check from blk_save_vmstateblock/block-backend.c+1 -10 replies
4/6block, migration: add bdrv_finalize_vmstate helperblock/block-backend.c block/io.c include/block/block.h +1 more+29 -14 replies
5/6block/io: improve savevm performanceblock/io.c include/block/block_int.h+132 -20 replies
6/6block/io: improve loadvm performanceblock/block-backend.c block/io.c include/block/block_int.h+250 -41 reply

Reviews trailers per patch

5 of 6 patches have a Reviewed-by or Acked-by.

PatchVladimir Sementsov-Ogievskiy
1/6
2/6R-b
3/6R-b
4/6R-b
5/6R-b
6/6R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v8 thread

Cover letter [PATCH v8 0/6] block: seriously improve savevm/loadvm performance

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 Plotnikov
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 v7:
- dropped lock from LoadVMState
- fixed assert in last patch
- dropped patch 1 as queued

Changes from v6:
- blk_load_vmstate kludges added (patchew problem fixed)

Changes from v5:
- loadvm optimizations added with Vladimir comments included

Changes from v4:
- added patch 4 with blk_save_vmstate() cleanup
- added R-By
- bdrv_flush_vmstate -> bdrv_finalize_vmstate
- fixed return code of bdrv_co_do_save_vmstate
- fixed typos in comments (Eric, thanks!)
- fixed patchew warnings

Changes from v3:
- rebased to master
- added patch 3 which removes aio_task_pool_wait_one()
- added R-By to patch 1
- patch 4 is rewritten via bdrv_run_co
- error path in blk_save_vmstate() is rewritten to call bdrv_flush_vmstate unconditionally
- added some comments
- fixes initialization in bdrv_co_vmstate_save_task_entry as suggested

Changes from v2:
- code moved from QCOW2 level to generic block level
- created bdrv_flush_vmstate helper to fix 022, 029 tests
- added recursive for bs->file in bdrv_co_flush_vmstate (fix 267)
- fixed blk_save_vmstate helper
- fixed coroutine wait as Vladimir suggested with waiting fixes from me

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

CC Kevin Wolf <[email protected]>
CC Max Reitz <[email protected]>
CC Stefan Hajnoczi <[email protected]>
CC Fam Zheng <[email protected]>
CC Juan Quintela <[email protected]>
CC "Dr. David Alan Gilbert" <[email protected]>
CC Vladimir Sementsov-Ogievskiy <[email protected]>
CC Denis Plotnikov <[email protected]>