kornelski / cargo-deb

Make Debian packages directly from Rust/Cargo projects
https://lib.rs/cargo-deb
MIT License
431 stars 52 forks source link

Use `zopfli` instead of `flate2` for Gzip compression #112

Closed AlexTMjugador closed 1 year ago

AlexTMjugador commented 1 year ago

As mentioned in https://github.com/kornelski/cargo-deb/issues/100, cargo-deb used to use the Zopfli crate for compressing data using the Gzip format, which provides overall smaller results than other general-purpose Gzip encoders that cater to speed more. I think this is a good tradeoff for data meant to be compressed once and distributed or decompressed many times, such as Debian packages.

However, the zopfli crate API did not support the streaming Gzip encoding that cargo-deb moved to. This has changed with its latest v0.8.0 release, bringing it more on par with flate2, so that's no longer a reason to not use Zopfli.

I ran the available test suite and noticed no regressions due to this change.

kornelski commented 1 year ago

Cargo deb is also used for one-off deployment, without distribution. Including the --install flag.

This is why it has the --fast flag. Can you re-add support for it? (level() function on the compressor)

AlexTMjugador commented 1 year ago

Oh, sure, I was not aware of that, I can add that back! Would you prefer this flag to fall back to flate2, or would it be acceptable to run Zopfli with faster settings, such as fewer iterations or using only static DEFLATE blocks?

kornelski commented 1 year ago

It's fine to use zopfli if it can be in the same ballpark as fast zlib.

AlexTMjugador commented 1 year ago

Thanks! I did some quick benchmarks and noticed that Zopfli with fast settings is still noticeably slower than gzip/zlib/flate2, so I put flate2 back in when fast mode is enabled to avoid performance regressions in that case.

kornelski commented 1 year ago

Thank you