Fascinating--I wonder to what extent the performance improvements are due to the better constraints Rust hands over to LLVM for optimization (specifically thinking `noalias` rules) vs aggressiv code optimization by the developers to be to the point where they beat the C zlib. The latter could be more difficult to achieve given how long the original zlib has been getting incrementally improved, though.
zlib is really old and out of date, no real reason to use it except legacy. I think most optimization effort goes into newer compression libs like zstd.
Zlib-Rs Is Not Only Safer but Now Outperforming Zlib C Implementations
11–19 of 19 posts
Re: Zlib-Rs Is Not Only Safer but Now Outperforming Zlib C Implementations
#12Really interesting, I've never used the Rust version, I can only assume I've used the C implementation indirectly dozens of times if not hundreds, but does anyone know how 1:1 the Rust implementation is? The one area where C will always beat Rust (at least today) will probably always be portability, C compilers run everywhere, on everything, and to anything... Unless Rust has similar capabilities via LLVM?
From the GitHub page, they provide libz-rs-sys, a zlib-compatible C API for usage in non-Rust applications.
Re: Zlib-Rs Is Not Only Safer but Now Outperforming Zlib C Implementations
#13Fascinating--I wonder to what extent the performance improvements are due to the better constraints Rust hands over to LLVM for optimization (specifically thinking `noalias` rules) vs aggressiv code optimization by the developers to be to the point where they beat the C zlib. The latter could be more difficult to achieve given how long the original zlib has been getting incrementally improved, though.
zlib is really old and out of date, no real reason to use it except legacy. I think most optimization effort goes into newer compression libs like zstd.
I suspect the results won't be quite as good on Aarch64 or other architectures though. zlib-ng has a pretty wide range of hand-optimized intrinsics whereas zlib-rs seems to only really have x86_64.
Re: Zlib-Rs Is Not Only Safer but Now Outperforming Zlib C Implementations
#14Earlier quoted context omitted.
zlib is really old and out of date, no real reason to use it except legacy. I think most optimization effort goes into newer compression libs like zstd.
Legacy is a bit much. Deflate is probably the only supported compression format in many existing/live standards. For a greenfield project where you can control all clients, sure, use whatever, but zlib is likely going to continue to be used for decades.
Re: Zlib-Rs Is Not Only Safer but Now Outperforming Zlib C Implementations
#15Earlier quoted context omitted.
Legacy is a bit much. Deflate is probably the only supported compression format in many existing/live standards. For a greenfield project where you can control all clients, sure, use whatever, but zlib is likely going to continue to be used for decades.
EDIT: doh! Mixed up Zstd and Zlib. Nothing to see here. (Can't delete with a reply.)
Gzip/DEFLATE is mediocre on most metrics relevant to compression but it's widely used of course. Zstd is better all-around, but much newer and thus doesn't have the same level of adoption.
Re: Zlib-Rs Is Not Only Safer but Now Outperforming Zlib C Implementations
#16Re: Zlib-Rs Is Not Only Safer but Now Outperforming Zlib C Implementations
#17Earlier quoted context omitted.
zlib is really old and out of date, no real reason to use it except legacy. I think most optimization effort goes into newer compression libs like zstd.
The comparison is against zlib-ng, not the OG zlib. So this is still very impressive. I suspect the results won't be quite as good on Aarch64 or other architectures though. zlib-ng has a pretty wide range of hand-optimized intrinsics whereas zlib-rs seems to only really have x86_64.
Re: Zlib-Rs Is Not Only Safer but Now Outperforming Zlib C Implementations
#18Really interesting, I've never used the Rust version, I can only assume I've used the C implementation indirectly dozens of times if not hundreds, but does anyone know how 1:1 the Rust implementation is? The one area where C will always beat Rust (at least today) will probably always be portability, C compilers run everywhere, on everything, and to anything... Unless Rust has similar capabilities via LLVM?
Re: Zlib-Rs Is Not Only Safer but Now Outperforming Zlib C Implementations
#19Really interesting, I've never used the Rust version, I can only assume I've used the C implementation indirectly dozens of times if not hundreds, but does anyone know how 1:1 the Rust implementation is? The one area where C will always beat Rust (at least today) will probably always be portability, C compilers run everywhere, on everything, and to anything... Unless Rust has similar capabilities via LLVM?
To me, the point of using a Rust version over a C version of anything would be for memory safety not performance, so a 1:1 rewrite doesn’t make any sense ie. because what’s the point - you’ve now reproduced any memory dangers!