Blog Entry

Benchmarking mksquashfs with zstd compression


I set up a x86_64 ArchLinux chroot with the main packages:

base-devel
xfce4
xfce4-goodies

I then used mksquashfs with zstd compression with differing options as I wanted to see if there was a more ideal way to run mksquashfs.

The options I used were (in a Bash shell):

time mksquashfs chroot chroot_zstd_default.sqfs -comp zstd
time mksquashfs chroot chroot_zstd_l20.sqfs -comp zstd -Xcompression-level 20
time mksquashfs chroot chroot_zstd_l22.sqfs -comp zstd -Xcompression-level 22
time mksquashfs chroot chroot_zstd_ldef_b32k.sqfs -comp zstd -b $((32 * 1024))
time mksquashfs chroot chroot_zstd_l20_b32k.sqfs -comp zstd -Xcompression-level 20 -b $((32 * 1024))
time mksquashfs chroot chroot_zstd_l22_b32k.sqfs -comp zstd -Xcompression-level 22 -b $((32 * 1024))

The results:

736.234 MiB 771997696 Bytes May  2 17:50 chroot_zstd_l22.sqfs 241.150s
736.266 MiB 772030464 Bytes May  2 17:55 chroot_zstd_l20.sqfs 210.096s
741.141 MiB 777142272 Bytes May  2 17:45 chroot_zstd_default.sqfs 67.078s
781.422 MiB 819380224 Bytes May  2 18:01 chroot_zstd_l22_b32k.sqfs 191.463s
781.438 MiB 819396608 Bytes May  2 18:05 chroot_zstd_l20_b32k.sqfs 171.800s
787.645 MiB 825905152 Bytes May  2 17:57 chroot_zstd_ldef_b32k.sqfs 51.588s

Results sorted by time:

51.588s chroot_zstd_ldef_b32k.sqfs 825905152
67.078s chroot_zstd_default.sqfs 777142272
171.800s chroot_zstd_l20_b32k.sqfs 819396608
191.463s chroot_zstd_l22_b32k.sqfs 819380224
210.096s chroot_zstd_l20.sqfs 772030464
241.150s chroot_zstd_l22.sqfs 771997696

From these results, it appears that the default settings for zstd compression with mksquashfs is pretty sane, and I probably will keep to it.

Revisiting the benchmark

I created an x86_64 chroot again because I wanted to do more tests.

On ArchLinux, used mkarchroot chroot base-devel xfce4 xfce4-goodies.

du -sh shows the size of the chroot as 1.8G .

(Note that by default mksquashfs uses a compression level of 15 for zstd, and a block size of 128KiB.)

The options used:

time mksquashfs chroot chroot_default.sqfs -comp zstd
time mksquashfs chroot chroot_ldef_b32k.sqfs -comp zstd -b $((32 * 1024))
time mksquashfs chroot chroot_ldef_b256k.sqfs -comp zstd -b $((256 * 1024))
time mksquashfs chroot chroot_ldef_b512k.sqfs -comp zstd -b $((512 * 1024))
time mksquashfs chroot chroot_ldef_b1m.sqfs -comp zstd -b $((1024 * 1024))
time mksquashfs chroot chroot_l20_bdef.sqfs -comp zstd -Xcompression-level 20
time mksquashfs chroot chroot_l20_b32k.sqfs -comp zstd -Xcompression-level 20 -b $((32 * 1024))
time mksquashfs chroot chroot_l20_b256k.sqfs -comp zstd -Xcompression-level 20 -b $((256 * 1024))
time mksquashfs chroot chroot_l20_b512k.sqfs -comp zstd -Xcompression-level 20 -b $((512 * 1024))
time mksquashfs chroot chroot_l20_b1m.sqfs -comp zstd -Xcompression-level 20 -b $((1024 * 1024))
time mksquashfs chroot chroot_l22_bdef.sqfs -comp zstd -Xcompression-level 22
time mksquashfs chroot chroot_l22_b32k.sqfs -comp zstd -Xcompression-level 22 -b $((32 * 1024))
time mksquashfs chroot chroot_l22_b256k.sqfs -comp zstd -Xcompression-level 22 -b $((256 * 1024))
time mksquashfs chroot chroot_l22_b512k.sqfs -comp zstd -Xcompression-level 22 -b $((512 * 1024))
time mksquashfs chroot chroot_l22_b1m.sqfs -comp zstd -Xcompression-level 22 -b $((1024 * 1024))

The results sorted by resulting file size:

433.934 MiB 455012352 Bytes 02:35.663 chroot_l22_b1m.sqfs
434.055 MiB 455139328 Bytes 02:04.382 chroot_l20_b1m.sqfs
444.102 MiB 465674240 Bytes 02:36.925 chroot_l22_b512k.sqfs
444.211 MiB 465788928 Bytes 02:06.067 chroot_l20_b512k.sqfs
456.980 MiB 479178752 Bytes 02:49.903 chroot_l22_b256k.sqfs
457.004 MiB 479203328 Bytes 02:39.195 chroot_l20_b256k.sqfs
463.270 MiB 485773312 Bytes 01:01.794 chroot_ldef_b256k.sqfs
471.898 MiB 494821376 Bytes 03:33.590 chroot_l22_bdef.sqfs
471.941 MiB 494866432 Bytes 03:06.594 chroot_l20_bdef.sqfs
474.711 MiB 497770496 Bytes 00:36.037 chroot_ldef_b1m.sqfs
478.460 MiB 501702656 Bytes 00:57.119 chroot_default.sqfs
485.387 MiB 508964864 Bytes 00:31.380 chroot_ldef_b512k.sqfs
512.133 MiB 537010176 Bytes 02:49.632 chroot_l22_b32k.sqfs
512.152 MiB 537030656 Bytes 02:33.842 chroot_l20_b32k.sqfs
520.066 MiB 545329152 Bytes 00:45.010 chroot_ldef_b32k.sqfs

The results sorted by time spent:

00:31.380 485.387 MiB 508964864 Bytes chroot_ldef_b512k.sqfs
00:36.037 474.711 MiB 497770496 Bytes chroot_ldef_b1m.sqfs
00:45.010 520.066 MiB 545329152 Bytes chroot_ldef_b32k.sqfs
00:57.119 478.460 MiB 501702656 Bytes chroot_default.sqfs
01:01.794 463.270 MiB 485773312 Bytes chroot_ldef_b256k.sqfs
02:04.382 434.055 MiB 455139328 Bytes chroot_l20_b1m.sqfs
02:06.067 444.211 MiB 465788928 Bytes chroot_l20_b512k.sqfs
02:33.842 512.152 MiB 537030656 Bytes chroot_l20_b32k.sqfs
02:35.663 433.934 MiB 455012352 Bytes chroot_l22_b1m.sqfs
02:36.925 444.102 MiB 465674240 Bytes chroot_l22_b512k.sqfs
02:39.195 457.004 MiB 479203328 Bytes chroot_l20_b256k.sqfs
02:49.632 512.133 MiB 537010176 Bytes chroot_l22_b32k.sqfs
02:49.903 456.980 MiB 479178752 Bytes chroot_l22_b256k.sqfs
03:06.594 471.941 MiB 494866432 Bytes chroot_l20_bdef.sqfs
03:33.590 471.898 MiB 494821376 Bytes chroot_l22_bdef.sqfs

I find these results interesting as larger block-size does not necessarily mean slower compression. For a reasonable compression, using default compression level with block-size of 1 MiB looks good. For the best compression, level 22 with block-size of 1 MiB isn't that bad considering the runtime.

Comments:

There are no comments for this post.