libarchive's xz offers single threaded xz compression which is very slow and provides ~10-20Mbps compression speed in addition to maxing a core. In exchange, it achieves optimal compression ratios among all our compression methods. Nonetheless, xz prevent the saturation of 1Gbps+ connections and slow down significantly decompression for end users. As these connections and faster hardware is becoming prevalent for cache servers and clients, we offer to default to zstd. Lix is a "compress once, decompress many times" application. To avoid incurring a high penalty to end users very sensitive to compress ratio (very slow Internet connections), we dampen the consequences of switching to zstd by increasing the default zstd level to 12. On one example, xz will compress a 4.4GB file to 632MB, zstd on 12 will compress it to 775MB, that is a ~18 % increase over the optimal xz compression. zstd took 18 seconds to produce this file. Increasing to level 14 leads to a 773MB file while taking 37s. Increasing to level 16 leads to 735MB file while taking 66s. Finally, xz took 77s, so a 50 % reduction in time taken to compress in exchange of an increase of 18 % of the compressed size. This change will reduce issues encountered in #945 but is probably not the root cause. References: - https://discourse.nixos.org/t/switch-cache-nixos-org-to-zstd-to-fix-slow-nixos-updates-nix-downloads/23961 Change-Id: I7beda2bf2c1fed146dcb797b8f85dc290c486ab2 Signed-off-by: Raito Bezarius <raito@lix.systems>
1.4 KiB
synopsis, issues, cls, category, credits
| synopsis | issues | cls | category | credits | ||||
|---|---|---|---|---|---|---|---|---|
| Enable high compress ratio zstd compression by default for binary caches uploads |
|
|
Breaking Changes |
|
The default compression method for binary cache uploads has been switched from
xz to
zstd to address performance and usability
issues related to modern hardware and high-speed connections.
Why?
xz offers compression ratios but is single-threaded in our implementation and
very slow (~10-20 Mbps in our test), preventing full utilization of 100Mbps+
connections and significantly slowing decompression for end users.
Lix is a "compress once, decompress many" application: build farms can afford to spend more time compressing to achieve a faster download transfer for the end user. More importantly, it matters that all end users spend the least amount of time decompressing.
What about compression ratios?
zstd cannot achieve the same peaks as xz, nonetheless, zstd compression
level has been increased to level 12 by default to balance compression ratio
and performance.
Synthetic test case data
- xz (default compression level) on a 4.4GB file: ~632MB (77s)
- zstd (level 12) on the same file: ~775MB (18s), 18% larger but 50% faster
- zstd (level 14): ~773MB (37s)
- zstd (level 16): ~735MB (66s)