Squashfs Compression and Container Startup times
May 24, 2021, Joachim Folz
We tested container startup times from SquashFS with lz4 and zstandard compression versus uncompressed files. Spoiler: compression is good.
Benchmarks #
Enroot uses SquashFS as its container image format, which supports different lossless compression methods depending on the Linux kernel version.
The newest addition is zstandard added in kernel 4.14.
Below is are some results for nvcr.io_nvidia_pytorch_21.05-py3.sqsh
with compressed size and startup times with different compression methods and threads available for decompression.
Compression | Size (GiB) | Threads | Start time (s) |
---|---|---|---|
none | 12 | 2 | 30 |
none | 12 | 4 | 30 |
none | 12 | 8 | 30 |
lz4 | 6.7 | 2 | 27 |
lz4 | 6.7 | 4 | 21 |
lz4 | 6.7 | 8 | 21 |
lz4 hc | 5.7 | 2 | 24 |
lz4 hc | 5.7 | 4 | 20 |
lz4 hc | 5.7 | 8 | 20 |
zstd lvl 15 | 4.4 | 2 | 29 |
zstd lvl 15 | 4.4 | 4 | 21 |
zstd lvl 15 | 4.4 | 8 | 17 |
zstd lvl 22 | 4.3 | 2 | 30 |
zstd lvl 22 | 4.3 | 4 | 22 |
zstd lvl 22 | 4.3 | 8 | 18 |
Conclusion #
As we can see, zstandard provides best compression by a large margin, beating the second best entry lz4 hc (high compression) by about 23%. Zstandard is slightly slower than lz4 hc if only 2 threads are used for decompression, but they are comparable for 4 or more threads. Most importantly compression provides significant savings up to 64% in terms of storage space and is always faster than uncompressed images.