rules_pkg
rules_pkg copied to clipboard
Support zstd as first-class compression scheme
https://github.com/facebook/zstd/ is another compression format with highly tunable compression format that highly desirable performance characteristics. It would be nice if it were supported locally without having to specify an external compressor, when we are able to easily do so.
Notes that come to mind:
- zstd in python3 requires external library bindings
- On top of that zstd in zip files is not immediately supported without changes to the standard library
pkg_tar(and thuspkg_deb) can rely on an external compressorpkg_rpmcan compress with zstd by passingbinary_payload_compression = "w$LEVEL.zstdio, where$LEVELis a numeric compression level. This requireszstdsupport in the localrpmbuildbinary.pkg_debis kinda up in the air: the Debian package format does not appear to supportzstdyet, but apparently ubuntu is already using it. See also https://www.phoronix.com/scan.php?page=news_item&px=Ubuntu-21.10-Zstd-Debs, https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=892664.
If it helps, I have a BUILD file to build zstd from source that we use extensively in our rule set, which I could contribute here. No promisses about how well it works outside of linux/x64, but it was basically transliterated from their BUCK build file. For our own use cases we just pass that executable as the compressor executable for pkg_tar.
It would be more useful to release it to a distinct repo so other rules can use it. Or.... and this would probably be difficult ... upstream it to the zstd repo.
They might accept it? https://github.com/facebook/zstd/issues/3123
@adam-azarchs mind sharing your build file/example if you have it handy?
Sure, attached here BUILD.zstd.bazel. Note:
- I didn't put any effort into checking whether it works on platforms besides linux/x64
- I didn't enable support for features I don't need (like zlib support in the
zstdexecutable, or support for "legacy" mode). - It's using our own internal fork of
rules_licensewhich has some additional fields which aren't supported by the main branch.