-
Notifications
You must be signed in to change notification settings - Fork 176
Add a pure-Rust backend #67
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
Comments
There are existing 'deflate' and 'inflate' crates that might be suitable. |
Developer of the |
Notes from today's libs team meeting:
Currently we do not plan to pursue a pure-Rust backend for flate2. Instead we plan to promote migration to pure Rust crates as they become stable. |
Would a drop-in pure rust replacement of miniz be useful anyway? We have summer internships at https://compscicenter.ru, and porting a C library to Rust seems like an interesting project (given that you can throw corrode, ALF and all other cool tools at it) which I probably can mentor. |
I'd imagine so yeah! ABI compatible, yet safe, libraries seem like a fantastic use case for Rust. |
I made a fork that uses miniz_oxide. Right now miniz.c file is fully ported to Rust and a little bit from tdef. |
Deflation is done (except for png functions), but it certainly can be a bit rustier. As a whole miniz_tester.cpp is working 1.09 (SE 0.01) times slower with miniz_oxide according to /usr/bin/time user time. |
The performance of miniz_oxide for deflating looks really good!
(The test prefixed with flate2 is the ones using flate2) Let me know if you want me to help out on making it more rusty. I suppose porting the miniz backend for flate2 may be an easier route to get rid of this dependency on a C-library than trying to approach the speed with the current pure-rust decoders. |
writer_create_flate2 is slower probably because I 0-set all the arrays at init. Valgrind is actually reporting conditional jumps based on uninitialized values in miniz because of that. |
Yeah it's probably 0-initialization taking a little bit of time. I believe the reading of uninitialized values is because it may read past the end of the input buffer when comparing matches as it doesn't check if it's hit the end. Zlib does something like that deliberately to avoid doing too many bounds checks when comparing matches. |
Nice work @Frommi! Those are some really encouraging numbers :) |
With help from @oyvindln inflation is now rewritten as well. miniz_oxide should already be usable, but there is still some work to be done like comprehensive fuzzing, testing for ARMs and some optimizations. |
Good news! Compression in miniz_oxide is now faster than in miniz on big enough files. Decompression still needs some work, though. Bench results:
|
Any updates on this? :) |
miniz_oxide is pretty much ready to be added as an experimental back-end now. |
big-endian issues have been fixed. @alexcrichton |
Nice progress! Want to make a PR with the changes here? For now I think we'll still want it off by default, but we could add an opt-in feature and get it on CI |
Okay, we will publish it on crates.io first and then make a PR here. By the way, here are current benchmarks vs miniz:
|
To anyone following this issue but not pull requests, this was added in #128. |
flate2 gets its actual compression from either libz or miniz, both C libraries. Ultimately, a pure-Rust stack is better for Rust, mostly because of build simplicity.
Write a miniz replacement in Rust, publish it to crates.io and add another compile-time feature to select it.
Then make the performance better than miniz and make it the default.
The text was updated successfully, but these errors were encountered: