Blame SOURCES/0056-v2v-Optimize-convert-for-images-with-small-holes.patch

da373f
From 48718639cc7fc5f93260b00553397ccb3faa7bbc Mon Sep 17 00:00:00 2001
3efd08
From: Nir Soffer <nirsof@gmail.com>
3efd08
Date: Fri, 1 Nov 2019 22:56:18 +0100
3efd08
Subject: [PATCH] v2v: Optimize convert for images with small holes
3efd08
MIME-Version: 1.0
3efd08
Content-Type: text/plain; charset=UTF-8
3efd08
Content-Transfer-Encoding: 8bit
3efd08
3efd08
"qemu-img convert" detects zeroes in allocated areas and punch holes in
3efd08
the destination image. This may save space on the destination image, but
3efd08
slows down conversion when using outputs such as rhv-upload, which have
3efd08
very large overhead per requests.
3efd08
3efd08
Using the -S flag, we can treat small areas filled with zeroes as data,
3efd08
limiting the number of requests, and speeding the operation.
3efd08
3efd08
Here is an example converting Fedora 30 image:
3efd08
3efd08
$ virt-builder fedora-30 -o src.img
3efd08
...
3efd08
3efd08
$ qemu-img map -f raw --output json src.img | wc -l
3efd08
213
3efd08
3efd08
$ qemu-img convert -f raw -O raw -t none -T none src.img dst.img
3efd08
3efd08
$ qemu-img map -f raw --output json dst.img | wc -l
3efd08
1443
3efd08
3efd08
$ ls -lhs *.img
3efd08
1.2G -rw-r--r--. 1 nsoffer nsoffer 6.0G Nov  1 21:48 dst.img
3efd08
1.2G -rw-r--r--. 1 nsoffer nsoffer 6.0G Nov  1 21:46 src.img
3efd08
3efd08
Qemu did 1443 writes instead of 213 (5.8X). Lets repeat this conversion
3efd08
with the -S option:
3efd08
3efd08
$ qemu-img convert -f raw -O raw -t none -T none -S 64k src.img dst.img
3efd08
3efd08
$ qemu-img map -f raw --output json dst.img | wc -l
3efd08
213
3efd08
3efd08
$ ls -lhs *.img
3efd08
1.2G -rw-r--r--. 1 nsoffer nsoffer 6.0G Nov  1 21:48 dst.img
3efd08
1.2G -rw-r--r--. 1 nsoffer nsoffer 6.0G Nov  1 21:46 src.img
3efd08
3efd08
Picking a good value for -S is not easy. Testing show that 64k is best
3efd08
value for this test image for limiting the number of requests:
3efd08
3efd08
$ for size in 4k 8k 16k 32k 64k; do \
3efd08
    printf "%5s: " $size; \
3efd08
    qemu-img convert -f raw -O raw -t none -T none -S $size src.img dst.img; \
3efd08
    qemu-img map -f raw --output json dst.img | wc -l; \
3efd08
done
3efd08
   4k: 1443
3efd08
   8k: 731
3efd08
  16k: 521
3efd08
  32k: 387
3efd08
  64k: 213
3efd08
3efd08
We need more testing with oVirt to measure the performance improvement
3efd08
and pick a good value. This should probably be an option, but lets start
3efd08
with a minimal change.
3efd08
3efd08
(cherry picked from commit 2aa78ade2d48e926b7b04050338ebd8a0c5e3f05
3efd08
in virt-v2v)
3efd08
---
3efd08
 v2v/v2v.ml | 1 +
3efd08
 1 file changed, 1 insertion(+)
3efd08
3efd08
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
3efd08
index d7a868659..a81a2320a 100644
3efd08
--- a/v2v/v2v.ml
3efd08
+++ b/v2v/v2v.ml
3efd08
@@ -754,6 +754,7 @@ and copy_targets cmdline targets input output =
3efd08
         (if not (quiet ()) then [ "-p" ] else []) @
3efd08
         [ "-n"; "-f"; "qcow2"; "-O"; t.target_format ] @
3efd08
         (if cmdline.compressed then [ "-c" ] else []) @
3efd08
+        [ "-S"; "64k" ] @
3efd08
         [ overlay_file; filename ] in
3efd08
       let start_time = gettimeofday () in
3efd08
       if run_command cmd <> 0 then
3efd08
-- 
da373f
2.18.4
3efd08