Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add convert sub command to example program
Add convert subcommand using the new convert package and include the new command in the functional tests. The new example is also good way to benchmark the library with real images as we can see bellow. Testing show significant speedup for compressed images and for unallocated or zero clusters, and smaller speedup for uncompressed images. | image | size | compression | throughput | speedup | |--------------|-----------|-------------|--------------|---------| | Ubuntu 24.04 | 3.5 GiB | - | 6.04 GiB/s | 1.51 | | Ubuntu 24.04 | 3.5 GiB | zlib | 1.62 GiB/s | 5.42 | | Empty image | 100.0 GiB | - | 240.15 GiB/s | 7.32 | Ubuntu 24.04 image in qcow2 format: % hyperfine -w3 "./go-qcow2reader-example read /tmp/images/test.qcow2 >/tmp/tmp.img" \ "./go-qcow2reader-example convert /tmp/images/test.qcow2 /tmp/tmp.img" Benchmark 1: ./go-qcow2reader-example read /tmp/images/test.qcow2 >/tmp/tmp.img Time (mean ± σ): 874.8 ms ± 41.3 ms [User: 64.3 ms, System: 717.5 ms] Range (min … max): 851.9 ms … 985.3 ms 10 runs Benchmark 2: ./go-qcow2reader-example convert /tmp/images/test.qcow2 /tmp/tmp.img Time (mean ± σ): 579.4 ms ± 22.8 ms [User: 90.5 ms, System: 681.2 ms] Range (min … max): 556.0 ms … 631.3 ms 10 runs Summary './go-qcow2reader-example convert /tmp/images/test.qcow2 /tmp/tmp.img' ran 1.51 ± 0.09 times faster than './go-qcow2reader-example read /tmp/images/test.qcow2 >/tmp/tmp.img' Ubuntu 24.04 image in qcow2 compressed format: % hyperfine -w3 -r3 "./go-qcow2reader-example read /tmp/images/test.zlib.qcow2 >/tmp/tmp.img" \ "./go-qcow2reader-example convert /tmp/images/test.zlib.qcow2 /tmp/tmp.img" Benchmark 1: ./go-qcow2reader-example read /tmp/images/test.zlib.qcow2 >/tmp/tmp.img Time (mean ± σ): 11.702 s ± 0.200 s [User: 10.423 s, System: 1.121 s] Range (min … max): 11.533 s … 11.923 s 3 runs Benchmark 2: ./go-qcow2reader-example convert /tmp/images/test.zlib.qcow2 /tmp/tmp.img Time (mean ± σ): 2.161 s ± 0.027 s [User: 10.980 s, System: 1.032 s] Range (min … max): 2.139 s … 2.191 s 3 runs Summary './go-qcow2reader-example convert /tmp/images/test.zlib.qcow2 /tmp/tmp.img' ran 5.42 ± 0.11 times faster than './go-qcow2reader-example read /tmp/images/test.zlib.qcow2 >/tmp/tmp.img' 100 GiB empty sparse image in qcow2 format. Comparing to the read command is not useful since it writes 100 GiB of zeros, so I'm comparing 1 and 8 workers. % hyperfine -w3 "./go-qcow2reader-example convert -workers 1 /tmp/images/test.0p.qcow2 /tmp/tmp.img" \ "./go-qcow2reader-example convert -workers 8 /tmp/images/test.0p.qcow2 /tmp/tmp.img" Benchmark 1: ./go-qcow2reader-example convert -workers 1 /tmp/images/test.0p.qcow2 /tmp/tmp.img Time (mean ± σ): 3.050 s ± 0.023 s [User: 2.991 s, System: 0.054 s] Range (min … max): 3.036 s … 3.107 s 10 runs Benchmark 2: ./go-qcow2reader-example convert -workers 8 /tmp/images/test.0p.qcow2 /tmp/tmp.img Time (mean ± σ): 416.4 ms ± 3.4 ms [User: 3252.7 ms, System: 16.3 ms] Range (min … max): 412.0 ms … 421.9 ms 10 runs Summary './go-qcow2reader-example convert -workers 8 /tmp/images/test.0p.qcow2 /tmp/tmp.img' ran 7.32 ± 0.08 times faster than './go-qcow2reader-example convert -workers 1 /tmp/images/test.0p.qcow2 /tmp/tmp.img' Signed-off-by: Nir Soffer <[email protected]>
- Loading branch information