Consider switching SquashFS compression to zstd
Rationale
Compared to our current crazy-size-optimized XZ settings, in theory zstd should give us:
- faster compression ⇒ improves dev & RM experience
- vastly faster decompression ⇒ improves performance for users
- only slightly larger output ⇒ makes install/upgrade downloads take a little longer
Regarding tooling, zstd is supported by:
squashfs-tools-ng
- Linux kernel
-
squashfs-tools
4.4+
Benchmarks
Image size
With defaultcomp
(release):
- xz: 1130M
- zstd: 1256M → +126M i.e. +11%
Compression speed
system | compression | time to compress SquashFS | build time saved |
---|---|---|---|
sib | xz (release) | 537s | n/a |
sib | zstd (release) | 299s | 238s |
ant01 | xz (release) | 404s | n/a |
ant01 | zstd (release) | 220s | 184s |
lizard | xz (release) | 910s | n/a |
lizard | zstd (release) | 519s | 391s |
iguana | xz (release) | 393s | n/a |
iguana | zstd (release) | 263s | 130s |
intrigeri's laptop | xz (fast) | 265s | n/a |
intrigeri's laptop | zstd (fast) | 170s | 95s |
boyska's desktop | xz (fast) | 62s | n/a |
boyska's desktop | zstd (fast) | 33s | 29s |
Conclusions
release (defaultcomp)
We cannot switch to zstd as-is: the image grows too much.
We have 2 options:
With squashfs-tools
Append, to our SquashFS sort file, the files that are not added to it by boot-profile
, grouped by filename extension. This can save about 5% on the image size.
I tried this and saw no impact at all on the image size:
- https://gitlab.tails.boum.org/tails/tails/-/tree/wip/18655-zstd-squashfs
- https://gitlab.tails.boum.org/tails/live-build/-/commits/tails/update-squashfs-sort-file
With squashfs-tools-ng
Branches:
- https://gitlab.tails.boum.org/tails/tails/-/tree/wip/18655-squashfs-tools-ng
- https://gitlab.tails.boum.org/tails/live-build/-/tree/tails/squashfs-tools-ng
If the former is not sufficient, then we could switch to squashfs-tools-ng
, if upstream can add advanced compression options (bcj filters, dictionary) that give us ISO/USB image not much greater than our current ones, with better performance on users' systems (and hopefully not slower to build on CI and RM's machines). For this to happen:
-
Base this work on feature/bullseye
or backportsquashfs-tools-ng
to Buster -
Build a version of our live-build
fork that usesgensquashfs
-
Advanced zstd compression option: request this from upstream -
SquashFS file ordering - SquashFS file ordering is very useful even with USB sticks (#15915 (comment 21450)).
- Support is being added upstream (https://github.com/AgentD/squashfs-tools-ng/issues/94, pushed to
master
on 2021-11-01). - Adjust our code and SquashFS sort file to
gensquashfs
's sort file format
-
Replace mksquashfs-excludes
-
First, narrow down the problem a little bit (!649 (merged)) -
Update
mksquashfs-excludes
: some of these excludes are obsolete. -
Delete as many of these files as possible via
config/chroot_local-hooks/
-
-
Remove as much as possible via config/binary_rootfs/excludes
: this covered all the remaining excluded files
-
dev (fastcomp)
It seems switching has only benefits → !643 (merged).