Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using Image.Next() to skip zero extents instead of reading and detecting zeros. We still detect zeroes in non-zero extents to convert areas full of actual zeros to unallocated area in the target image. This does not change much the performance for the Ubuntu image since most of the time is spent on reading and decompressing the actual data. Converting a large empty image is 2 orders of magnitude faster, so I'm testing now 1 TiB image instead of 100 GiB image. Example run with 1 TiB empty image: % hyperfine -w3 "qemu-img convert -f qcow2 -O raw -W /tmp/images/test.0p.qcow2 /tmp/tmp.img" \ "./go-qcow2reader-example convert /tmp/images/test.0p.qcow2 /tmp/tmp.img" Benchmark 1: qemu-img convert -f qcow2 -O raw -W /tmp/images/test.0p.qcow2 /tmp/tmp.img Time (mean ± σ): 14.0 ms ± 0.4 ms [User: 11.8 ms, System: 2.0 ms] Range (min … max): 13.5 ms … 17.8 ms 181 runs Benchmark 2: ./go-qcow2reader-example convert /tmp/images/test.0p.qcow2 /tmp/tmp.img Time (mean ± σ): 20.6 ms ± 0.2 ms [User: 118.9 ms, System: 2.2 ms] Range (min … max): 20.4 ms … 21.7 ms 130 runs Summary qemu-img convert -f qcow2 -O raw -W /tmp/images/test.0p.qcow2 /tmp/tmp.img ran 1.48 ± 0.04 times faster than ./go-qcow2reader-example convert /tmp/images/test.0p.qcow2 /tmp/tmp.img qemu-img is faster but 7 millisecond difference for 1 TiB image is not very interesting. Signed-off-by: Nir Soffer <[email protected]>
- Loading branch information