libpng was written before x86 had SIMD. If you look at how it writes loops, something that stands out is that the C style is often one that modern compilers can't auto-vectorize even if they tried very hard to, such as
The Rust implementation is also faster than the newer stb library even though it copied stb's SIMD code.
This Rust library dates back to 2014, which is like K&R C for Rust. That was before Rust 1.0.0 release, before Rust had any SIMD support, before Rust had noalias support.
But with the safety guarantees, and painless testing and benchmarking tooling, Rust codebases are easier to refactor and evolve.
Isn't that partially the point? The canonical C libraries could be just as fast if they used the same approach, but they don't, in large part because their codebases are so difficult to work with and any significant changes or rewrites could easily introduce catastrophic security bugs. The nature of the language encourages the fossilisation of battle tested code even if it's well past its prime.
Nothing to do with the nature of the language. Rather it is to do with the nature of humans. Rust code when it is old enough to be referred to as "fossilised" will also likely evoke the same (lack of) interest in large scale refactors. The next generation will then repeat your comment for the trendy language of their times.
They can't, because the restrict keyword in C is a huge footgun. This isn't manual vectorization. The Rust compiler is emitting noalias everywhere, which allows LLVM to autovectorize more of the codebase without the developer having to do anything special like use a SIMD library or intrinsics.
This is the first "rewrite it in rust" reason I've heard that actually makes total sense, congratulations. Ability to safely hack on ancient code really does sound attractive
https://github.com/pnggroup/libpng/blob/c1cc0f3f4c3d4abd11ca...
IMHO you need a lot of asterisks*** when you're advertising language comparisons against reference C that was optimized in the 1990's.
edit: (That code snippet simply inflates an array of bits into an array of the matching bytes (0x00 or 0xff)).