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

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • dlq84
    Senior Member
    • Jul 2012
    • 425

    #31
    Originally posted by Raka555 View Post
    Lets talk again in a few years when someone has to maintain this ...

    image.png
    Is that your example of complicated code??? Haha maybe you should stick to Scratch.

    You learn all that in the rust for beginners book. Seriously 😅

    Comment

    • Tobu
      Phoronix Member
      • Jun 2012
      • 61

      #32
      Originally posted by sobrus View Post
      C and Rust are more or less equally performant and both gcc and rustc (llvm? As far as I know rustc uses llvm as a compiler backend) feature autovectorization (can automatically use avx).
      It's (most probably) just that the newer decoder implementation is simply better.
      The advantages of rust are more than just pure speed. Usually pure C has very slight speed advantage anyway.
      I've read the Reddit thread, I've read the comments, Shnatsel's post is more clueful than this whole forum thread. The fastest entry (image-rs PNG) has moved from explicit SIMD to autovectorisation (for all but one filter). It does require a particular way to write the code, and feedback from looking at the assembly, it's not magical. Autovectorisation works better in Rust than in C because Rust tracks when things might alias or won't. In C you'd have to annotate manually, the compiler would give you no help making the annotations correct or forwarding requirements to callers, so to get equivalent speed libpng would risk UB and vulnerabilities.
      Last edited by Tobu; 09 December 2024, 12:48 PM.

      Comment

      • Volta
        Senior Member
        • Apr 2019
        • 2237

        #33
        Originally posted by bug77 View Post

        The tragedy of C: always "can be", never "is".
        Actually opposite. Any big rust project comparable to Linux or PostgreSQL? Not even close!

        Comment

        • Raka555
          Junior Member
          • Nov 2018
          • 674

          #34
          Originally posted by dlq84 View Post

          Is that your example of complicated code??? Haha maybe you should stick to Scratch.

          You learn all that in the rust for beginners book. Seriously 😅
          Unreadable, not complicated.

          Comment

          • Raka555
            Junior Member
            • Nov 2018
            • 674

            #35
            c++ is not any better though:

            image.png

            Comment

            • Volta
              Senior Member
              • Apr 2019
              • 2237

              #36
              Originally posted by dlq84 View Post

              Where do you see them? All I see are people with rust derangement syndrome hating on the language. At least the posts before you.
              It's the answer to rustards syndrome hating on non rustards language and rustards propaganda spread everywhere. Not to mention rust foundation that should be immediately eliminated.

              Comment

              • Raka555
                Junior Member
                • Nov 2018
                • 674

                #37
                Originally posted by Raka555 View Post
                c++ is not any better though:

                image.png
                Can you see why people prefer Python?
                image.png

                Comment

                • amxfonseca
                  Phoronix Member
                  • Sep 2019
                  • 88

                  #38
                  Originally posted by chuckula View Post
                  Uh... You literally cited some ancient SSE intrinsic code to call *me* "dumb" for correctly pointing out that the C library wasn't optimized for a completely different SIMD implementation on a completely different architecture??
                  No, I call you dumb because you seem to struggle with basic reading comprehension or any kind of basic research skill. Since everything you seem to post is factually incorrect.

                  You start with something like:
                  Originally posted by chuckula View Post
                  So this isn't really an advertisement for RUST, it's an advertisement for AVX256 & AVX512. Which I do like, but let's not conflate things.


                  Failing to realise that there isn't any kind of AVX optimisation in place. After someone rightfully corrects your DUMB statement, you go and double down on your rant and come up with a newer and even DUMBER conclusion:
                  Originally posted by chuckula View Post

                  Well since it's for "performance" benchmarks on niche platforms where the original C libraries were never even optimized in the first place then it actually supports my point even more than if it was x86


                  Not even bothering to check that the filters of the C libraries (libpng) are indeed optimised (and maintained) for multiple architectures, including X86 (SSE2), ARM (NEON), MIPS (MMI and MSA), PowerPC (VSX) and even LoongArch (LSX).


                  So you either are that dumb, or just a bad troll (worst than a bot).

                  Facts:
                  - Both implementations (Rust and libpng) optimise the filter code by using simple SIMD instructions (and no AVX)
                  - libpng relies on hand crafted optimisations written by the almighty C developers for multiple architectures
                  - png crate relies on automatic vectorization generated by the compiler, since Rust developers are inferior and incapable of writing code

                  Observed result (aka reality):
                  - Compiler produces faster code than superior elite developers.

                  No one is surprised, modern compilers are that good! Combine that with a clean and modern language (doesn't even need to be Rust) and you have a killer combo.

                  But just like flat-earthers, you prefer to ignore the simple and most obvious explanation and have the need come up with a bunch of contrived arguments that fit your alternate reality.

                  Comment

                  • bacteriamanicure
                    Phoronix Member
                    • Feb 2024
                    • 66

                    #39
                    Originally posted by Raka555 View Post
                    Lets talk again in a few years when someone has to maintain this ...

                    image.png
                    Guy who would rather just memorize all the complexity

                    Comment

                    • Raka555
                      Junior Member
                      • Nov 2018
                      • 674

                      #40
                      Originally posted by dlq84 View Post

                      Is that your example of complicated code??? Haha maybe you should stick to Scratch.

                      You learn all that in the rust for beginners book. Seriously 😅
                      And this is also not complicated code, but it is written in APL

                      image.png

                      Same kind of readability issues ... and yeah you will be able to read it for a while after spending some time with the APL beginners book.
                      Last edited by Raka555; 09 December 2024, 01:39 PM.

                      Comment

                      Working...
                      X