-
Notifications
You must be signed in to change notification settings - Fork 204
Conversation
Thank you for your contribution. However, I do not think this is the way to go as some people building for wasm were not able to use flate2. I was working on a branch for allowing people to choose their own library as needed, but have not found the time to finish it. See the plugin branch in this repository. Some further questions:
|
flate2 should work for WASM, ref. rust-lang/flate2-rs#161.
Done. |
I am now making an auditing pass over libflate, and its memory safety story is not great. Here are just the bugs I've found: |
Cargo.toml
Outdated
deflate = ["libflate"] | ||
deflate = ["flate2/default"] | ||
deflate-zlib = ["flate2/zlib"] | ||
deflate-rust = ["flate2/rust_backend"] |
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.
If you want to make this a non-breaking change, rust backend should be the default so you would not require users to have a C-to-WASM compiler to build it.
AFAIK there is no reason to not use the Rust backend for flate2 in 2019. Last I looked at it, performance was on par with or slightly better than C, and it was in good shape safety-wise.
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.
Upon closer inspection, the safety of the Rust backend for flate2 is not great right now either:
Frommi/miniz_oxide#36
Frommi/miniz_oxide#47 (probably also applies to the C backend)
I'm working with maintainers of both crates on improving them, but I cannot guarantee that they'll be entirely safe after I'm done as I am NOT a security professional.
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.
Still looks better than libflate.
Also speed of flate2 is more than triple of libflate, unless that changes in libflate, flate2 is a clear winner.
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.
Latest release of miniz_oxide contains no unsafe code. It is now superior to libflate in every way.
@mvdnes What is the status of this PR? It would be great if it could be merged. Many crates, like tectonic and reqwest already depends on flate2, so using zip crate together with one the two make the application uses two distinct deflate implementations. |
Since you made some compelling arguments, I have decided to merge this. Thanks for the contribution! |
Thank you! |
doc: Rewrite pull_request_template.md
Closes #88.
This pull request switches back to
flate2
implementation of (DE)FLATE, fromlibflate
.flate2
is ahead oflibflate
, ref. #88 (comment).Also adds default value inWas using oldercp437.rs
since newerrustc
versions error on missing_
resolution.rustc
by mistake.Benchmarks
All benchmarks were ran on
release
build (cargo build --release
) of a program usingzip-rs
- HEMTT. Code is usingBufReader
,BufWriter
andcopy
(instead of buffer) - code below.On Arch Linux 5.1.8. Only zipping in the program was timed (using
std::time
).ACE3 Folder Size is is different due to different build process on Windows - irrelevant for this.
Linux
libflate
Speedflate2
Speedlibflate
Zip Sizeflate2
Zip SizeWindows
libflate
Speedflate2
Speedlibflate
Zip Sizeflate2
Zip SizeBenchmark Code
Excerpt from the program, where it is timed.