-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Use improved compression algorithms when building DEB packages. #21310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
XZ compression is the de-facto standard compression used for DEB packages on Ubuntu prior to Ubuntu 21.10 and Debian prior to Debian 12. Using XZ for DEB package compression incurs a nontrivial performance hit for the installation of the packages (specifically, the process of unpacking the packages), but provides a roughly 34% space savings for the whole collection of packages compared to our current usage of gzip compression (tested using Debian 13 packages) and unlike the newer zstd compression has been supported by dpkg for long enough that we don’t really have to worry about any given system not supporting it.
Zstd compression is supported, and used by default, in Debian and Ubuntu starting with Debian 12 and Ubuntu 21.10. Compared to gzip compression, zstd provides a roughly 8.6% reduction in the total size of a full set of our packages (tested using Debian 13 packages), while at the same time reducing the overhead of unpacking the package for installation. Compared to the XZ compression that the previous commit enabled by default for our packages, zstd results in roughly 38% larger packages, but it completely removes the overhead on installation that XZ imposes, and is thus generally considered enough of a net improvement that both Debian and Ubuntu have pivoted from using XZ for package compression for their distribution packages to using zstd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 1 file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All debian packages created with this PR are installed with success. LGTM!
Updated: PR tested on Ubuntu 20.04.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates DEB package compression from gzip to more efficient algorithms, improving space efficiency while maintaining compatibility with target distributions.
Key Changes:
- Sets XZ as the default compression algorithm for DEB packages (34.2% space savings)
- Implements runtime detection of OS distribution and version via
/etc/os-release - Uses zstd compression for Debian 12+ and Ubuntu 21.10+ (8.6% space savings with better decompression performance)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ata#21310) * Switch to XZ compression by default for DEB packages. XZ compression is the de-facto standard compression used for DEB packages on Ubuntu prior to Ubuntu 21.10 and Debian prior to Debian 12. Using XZ for DEB package compression incurs a nontrivial performance hit for the installation of the packages (specifically, the process of unpacking the packages), but provides a roughly 34% space savings for the whole collection of packages compared to our current usage of gzip compression (tested using Debian 13 packages) and unlike the newer zstd compression has been supported by dpkg for long enough that we don’t really have to worry about any given system not supporting it. * Enable zstd compression for DEB packages on platforms that support it. Zstd compression is supported, and used by default, in Debian and Ubuntu starting with Debian 12 and Ubuntu 21.10. Compared to gzip compression, zstd provides a roughly 8.6% reduction in the total size of a full set of our packages (tested using Debian 13 packages), while at the same time reducing the overhead of unpacking the package for installation. Compared to the XZ compression that the previous commit enabled by default for our packages, zstd results in roughly 38% larger packages, but it completely removes the overhead on installation that XZ imposes, and is thus generally considered enough of a net improvement that both Debian and Ubuntu have pivoted from using XZ for package compression for their distribution packages to using zstd. (cherry picked from commit 908e30b)
* Switch to XZ compression by default for DEB packages. XZ compression is the de-facto standard compression used for DEB packages on Ubuntu prior to Ubuntu 21.10 and Debian prior to Debian 12. Using XZ for DEB package compression incurs a nontrivial performance hit for the installation of the packages (specifically, the process of unpacking the packages), but provides a roughly 34% space savings for the whole collection of packages compared to our current usage of gzip compression (tested using Debian 13 packages) and unlike the newer zstd compression has been supported by dpkg for long enough that we don’t really have to worry about any given system not supporting it. * Enable zstd compression for DEB packages on platforms that support it. Zstd compression is supported, and used by default, in Debian and Ubuntu starting with Debian 12 and Ubuntu 21.10. Compared to gzip compression, zstd provides a roughly 8.6% reduction in the total size of a full set of our packages (tested using Debian 13 packages), while at the same time reducing the overhead of unpacking the package for installation. Compared to the XZ compression that the previous commit enabled by default for our packages, zstd results in roughly 38% larger packages, but it completely removes the overhead on installation that XZ imposes, and is thus generally considered enough of a net improvement that both Debian and Ubuntu have pivoted from using XZ for package compression for their distribution packages to using zstd. (cherry picked from commit 908e30b)
Summary
This PR updates our DEB package builds to utilize either XZ or zstd compression instead of the gzip compression we are currently using.
For Debian 12 and newer, and Ubuntu 21.10 and newer, we now use zstd for compression, which is consistent with what those distros use for their repository packages. This provides a roughly 8.6% space savings for a full collection of our packages in comparison to our existing gzip compression (tested using Debian 13 packages), as well as providing a slight reduction in decompression overhead when unpacking the packages.
For older versions of Debian and Ubuntu, we now use XZ for compression, which is also consistent with what those distros use for their repository packages. This provides an absolutely absurd 34.2% space savings for a full collection of our packages in comparison to our existing gzip compression (again, tested using Debian 13 packages), but at the cost of imposing a significantly higher decompression overhead when unpacking the packages.
Test Plan
Requires manual cross-checking to confirm that packages are being built with the new compression methods.
Compression of DEB packages can be checked by mounting the package file with
archivemount(available in almost all distro’s official repositories via a package of the same name) and inspecting the extension of thedata.tarfile.