News: 0001511132

  ARM Give a man a fire and he's warm for a day, but set fire to him and he's warm for the rest of his life (Terry Pratchett, Jingo)

Rust-Based, Memory-Safe PNG Decoders "Vastly Outperform" C-Based PNG Libraries

([Programming] 3 Hours Ago Rust-Based PNG Decoders Performance)


Video and image encoders/decoders written in the Rust programming language for its memory safety guarantees is often viewed as [1]one of the compelling areas for the programming language to better protect against malformed/malicious content especially within web browsers. Not only are Rust-based PNG image decoders proving to be more secure than C-based decoders, but the performance of the Rust solutions can be even faster.

Sergey Davidoff with the image-png and zune-png Rust projects shared that the team posted to Reddit some promising details around their own findings for memory-safe Rust PNG decoders being able to outperform common C PNG libraries by a significant margin.

The developers posted their findings [2]in a Reddit post and commented:

"Memory-safe implementations of PNG (png, zune-png, wuffs) now dramatically outperform memory-unsafe ones (libpng, spng, stb_image) when decoding images.

Rust png crate that tops our benchmark shows 1.8x improvement over libpng on x86 and 1.5x improvement on ARM."

The speedy performance does still depend upon architecture-specific SIMD optimizations so your mileage may vary. For the benchmarks posted on Reddit, they were using an AMD Zen 4 system.

In addition to being faster and more secure than the C-based PNG libraries, they also argue that these Rust-based solutions are production ready:

"Is this production-ready?

Yes!

All three memory-safe implementations support APNG, reading/writing auxiliary chunks, and other features expected of a modern PNG library.

png and zune-png have been tested on a wide range of real-world images, with over 100,000 of them in the test corpus alone. And png is used by every user of the image crate, so it has been thoroughly battle-tested.

WUFFS PNG v0.4 seems to fail on grayscale images with alpha in our tests. We haven't investigated this in depth, it might be a configuration issue on our part rather than a bug. Still, we cannot vouch for WUFFS like we can for Rust libraries."

It will be interesting to see how the adoption of Rust-based PNG implementation goes over the coming years along with other Rust-based image/video encoders and decoders.



[1] https://www.phoronix.com/news/Mozilla-Interest-JPEG-XL-Rust

[2] https://www.reddit.com/r/rust/comments/1ha7uyi/memorysafe_png_decoders_now_vastly_outperform_c/



Volta

Britoid

reba

Shnatsel

Volta

skeevy420

zexelon

V1tol

chuckula

"Message passing as the fundamental operation of the OS is just an
excercise in computer science masturbation. It may feel good, but you
don't actually get anything DONE."

- Linus Torvalds