Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
Programming

'Rust is So Good You Can Get Paid $20K to Make It as Fast as C' (itsfoss.com) 153

The Prossimo project (funded by the nonprofit Internet Security Research Group) seeks to "move the Internet's security-sensitive software infrastructure to memory safe code." Two years ago the Prossimo project made an announcement: they'd begun work on rav1d, a safer high performance AV1 decoder written in Rust, according to a new update: We partnered with Immunant to do the engineering work. By September of 2024 rav1d was basically complete and we learned a lot during the process. Today rav1d works well — it passes all the same tests as the dav1d decoder it is based on, which is written in C. It's possible to build and run Chromium with it.

There's just one problem — it's not quite as fast as the C version...

Our Rust-based rav1d decoder is currently about 5% slower than the C-based dav1d decoder (the exact amount differs a bit depending on the benchmark, input, and platform). This is enough of a difference to be a problem for potential adopters, and, frankly, it just bothers us. The development team worked hard to get it to performance parity. We brought in a couple of other contractors who have experience with optimizing things like this. We wrote about the optimization work we did. However, we were still unable to get to performance parity and, to be frank again, we aren't really sure what to do next.

After racking our brains for options, we decided to offer a bounty pool of $20,000 for getting rav1d to performance parity with dav1d. Hopefully folks out there can help get rav1d performance advanced to where it needs to be, and ideally we and the Rust community will also learn something about how Rust performance stacks up against C.

This drew a snarky response from FFmpeg, the framework that powers audio and video processing for everyone from VLC to Twitch. "Rust is so good you can get paid $20k to make it as fast as C," they posted to their 68,300 followers on X.com.

Thanks to the It's FOSS blog for spotting the announcement.

'Rust is So Good You Can Get Paid $20K to Make It as Fast as C'

Comments Filter:
  • by Anonymous Coward

    Why would zero-cost-abstraction (ZCA) be any slower using the same compiler architecture?

    Either yours or the existing C implementation, has bugs.

    • ...that runs faster, not the almost new Rust one, thats got the bugs.

      Yeah, that'll be it.

      • What "Decades old C" implementation of AV1 decoding?

        AV1 was released in March 2018.

        • He's talking about the C language and its compilers, not the specific implementation of handling AV1. I quite frankly like that some tech has made it easier to write code in modern languages like rust, but to be honest, I think all of this somewhat adds to the enshitification of code, rather than make programs more bug-free and robust. There is nothing wrong with C at all. You can just about fuck up a program in any language. Programming is a talent and an art, and some advances make it easier and faster, b
          • by Pieroxy ( 222434 )

            Programming is not an art, it's engineering. Decades of C programming has shown that *no* programmer at all is immune to bugs that are way too easy to do naturally when you can cast a pointer to an int and do whatever the fuck you want with it. True, it allows for insane optimization, but then you're subject to buffer overflows and other issues that come naturally with this lax attitude.

            This problem was solved decades ago by Java and the like. When your pointers are a first class citizen and not a glorified

    • by jonsmirl ( 114798 ) on Sunday May 18, 2025 @01:59PM (#65385289) Homepage

      If there are any people left who know assembly language, the way to solve this is to study how the generated assembly language differs. Rust is telling the back end to do something differently. Track this down and you have your answer.

      • by dfghjk ( 711126 ) on Sunday May 18, 2025 @02:09PM (#65385313)

        Why don't they just ask ChatGPT to fix it? AI can do programming jobs, right?

        • AI/LLMs are far too fond on delivering you Python code. When not asked to. Even when clearly specifying that you don't want Python.

      • Re: (Score:2, Redundant)

        by Kisai ( 213879 )

        Rust doesn't invoke Assembly. That is the problem. There is no way to invoke it because that defeats the purpose of using Rust.

        If you want speed, you ONLY write software in C. Not C++, C.
        If you want stability, you write software in whatever language has a stable runtime on all platforms.
        If you want compatibility, you only write software in C99 (due to correct floating point support)

        You only get intrinsics with C/C++, and then only with specific compilers and only on 64-bit https://learn.microsoft.com/en-us/

      • the way to solve this is to study how the generated assembly language differs

        Like executing extra code to check for various memory safety rules?

      • There is no "it's just a frontend". LLVM is a toolkit that can be used and abused to different degrees in different compiler passes. LLVM itself sure can use fine tuning, but misuse of it is probably the greatest source of inefficiency.
    • by DrXym ( 126579 )
      Probably the LLVM backend just isn't as good at optimizing code emited by the Rust compiler.
    • by serviscope_minor ( 664417 ) on Sunday May 18, 2025 @03:14PM (#65385457) Journal

      Why would zero-cost-abstraction (ZCA) be any slower using the same compiler architecture?

      The backend optimizer can only work with what it gets from the front end. In practice a mature front end will use lots of knowledge about the language to construct a good intermediate representation for the back end to make use of. My guess is that the Rust front end is not as mature as the C one.

  • "It's easier to make a working program fast, than to make a fast program work."

    (and "work" should always include "secure".)

    • I'd like it if you could speed up the program that helps my friend the traveling salesman produce an optimized route. The algorithm he has now works perfectly, but it's not very fast.
      • by Entrope ( 68843 )

        How much computation is he willing to spend to be sure his route is definitely as short as possible, rather than just "almost certainly pretty close" with a probabilistic, approximate algorithm?

        And how many stops does he need to support? 10 stops is only 3.6 million possible routes, which is easy to do exhaustively. 16 stops grows to 20 billion possible routes, but that wouldn't take very long either if you farm it out on a 1000-"thread" GPU.

    • Call bullshit (Score:5, Interesting)

      by Excelcia ( 906188 ) <slashdot@excelcia.ca> on Sunday May 18, 2025 @02:13PM (#65385327) Homepage Journal

      That's the Rust justification talking.

      Rust is to C as Duplo is to Lego. You can build anything with Rust, provably because it's Turing complete. Just as Duplo has interlocking blocks that, with enough of them and enough patience can be used to build anything. But it will either be twice as big or half as fast. Rust just has too much inherent friction to ever be as elegant or useful.

      Rust is an appropriate name for the language. Anything it touches needs "C"lr to fix.

      C doesn't tell you where you can go or what you can do. C doesn't look at your code and tell you "Sorry, I can't do that Dave". C will always, ALWAYS just open the fucking pod bay doors when you tell it to.

      Rust selects for poor programming skills. It selects for programmers who don't understand nuts and bolts and bit bashing and who don't understand why, yes, you still need to understand what a CPU is actually doing under the hood to make good, efficient programs. Hide all that, make bits and bytes dirty words, and you get programmers who don't know or care why their code is inefficient. Rust is a language that treats everyone like children you can't trust. You what happens when you do that? People act the way they are treated. C treats you like an adult, which selects for people who can handle that kind of responsibility.

      Language like Rust (or Go or C# or worse) and that trend are why we need multiple gigahertz computers with tens of gigabytes of RAM to run a word processor.

      • Rust is an appropriate name for the language. Anything it touches needs "C"lr to fix.

        You can't fix rust with sealer, because rust never sleeps. It requires acid.

        C treats you like an adult, which selects for people who can handle that kind of responsibility.

        I wish that were true, the second part I mean. There's just a lot of bad code out there instead, and then we get all these vulns with dumb causes that we've known about for decades.

        • You can't fix rust with sealer, because rust never sleeps. It requires acid.

          CLR [clrclean.com.au] is an acid-based rust remover

          • I was thinking more like naval jelly or Ospho, both of which are based on phosphoric acid. But a clean toilet is nice, too... for me to poop in. Isn't it ionic? Specifically, cationic?

      • I'll add that you probably learn more about programming and systems from a C program that goes wrong than a Rust program that can't go wrong (at least not in the same ways) and the former can help you become a better programmer, while the latter doesn't really teach you anything. On the other hand, missing an odd and/or occasional error situation in C can be disastrous. Review, testing and experience can help, but those are, unfortunately, not always the highest priorities.

        • Re:Call bullshit (Score:4, Interesting)

          by Waffle Iron ( 339739 ) on Sunday May 18, 2025 @04:16PM (#65385559)

          I'll add that you probably learn more about programming and systems from a C program that goes wrong than a Rust program that can't go wrong (at least not in the same ways) and the former can help you become a better programmer, while the latter doesn't really teach you anything.

          On the contrary, just getting a Rust program to successfully compile can teach you a whole lot about all the stuff you should have been worrying about with C or C++, but you were simply ignorant of or implicitly assumed would be OK.

      • Re:Call bullshit (Score:4, Insightful)

        by dunkelfalke ( 91624 ) on Sunday May 18, 2025 @03:16PM (#65385463)

        And this is the reason pretty much all software around has so many security issues - developers too full of themselves write crap in C.

        • by gweihir ( 88907 )

          That _must_ be the reason for all those PHP vulnerabilities and all that insecure Java and JavaScript code! I am enlightened now!

      • Gatekeep much? Jesus Christ. Most people have to learn to crawl before learning to walk, let alone run. Just because you could build a Lego Technics superkit straight out of the womb doesn't mean everyone else should be able to.

        I'd advise against break your arm patting yourself on the back too hard. Writing code with only one hand is at least 5% slower.

      • Re:Call bullshit (Score:5, Informative)

        by DrXym ( 126579 ) on Sunday May 18, 2025 @03:59PM (#65385535)
        It's clear from your comments you don't really have a clue about the language. Rust is a compiled language. It compiles to machine code through the same LLVM backend as C and produces functionality equivalent code. It can even call C or be called from C through native calls. It even runs on embedded systems. It's not garbage collected, it's not high level, it's a compiled language. Got it? And most of the checks you find so objectionable compile away to nothing at runtime and those that remain can be avoided easily, e.g. don't use random access on buffers, use iterators and so on. So no it's like Duplo vs Lego. It is just a better designed language than C that saves programmers from stupid errors like double frees, null pointers etc. Most people would see this as a good thing.
        • How does Rust handle situations that can't be detected at compile time? Say I have a networking program that receives arbitrarily sized data, and I have to allocate buffers which have sizes indicated in the packet header. I allocate the buffer according to the size in the packet, then start picking it apart. What will Rust do if/when I try to access data beyond the allocated buffer size?

        • by Uecker ( 1842596 )

          By your logic all compiled languages are equally fast. This is not the case.

        • I work at a major tech company and we have plenty of Rust projects and developers, and totally agree that it's not Duplos, but overall Rust is.. just fine. It's definitely not magic that makes code better and the toolchain is clearly immature. We have as many (and possibly even more) outstanding issues in our Rust code as any other codebase. IMHO, it's a language optimized for the wrong things (ie. stack allocation) at the expense of usability. It's no surprise that Rust performs a little worse than C code,
        • Re: (Score:2, Interesting)

          by Excelcia ( 906188 )

          It's clear from your comment that you didn't read what I wrote. All the languages I cited are compiled. Well, Rust and Go are. C# is just an illustration of why Rust is awful since it shares in some of Rust's moronicisms.

          Rust's scope-based ownership system is garbage collection, just at scope change time, not separately.
          Rust's inherent bounds checking, null-pointer dereference checking, abstraction overhead, and the borrow system all introduce unnecessary enforced overhead, overhead that is permanent and

          • by kertaamo ( 16100 )

            "Rust's inherent bounds checking, null-pointer dereference checking, abstraction overhead, and the borrow system all introduce unnecessary enforced overhead, overhead that is permanent and ongoing. "

            No. Most of Rusts checks are done at compile time without introducing any run time check overhead. Especially true of the borrow checker and null pointer checking. There may be bounds checks at run time but they can often be optimised away. They don't even exist if one uses Rusts iterators instead of indexing in

      • by gweihir ( 88907 )

        Rust selects for poor programming skills. It selects for programmers who don't understand nuts and bolts and bit bashing and who don't understand why, yes, you still need to understand what a CPU is actually doing under the hood to make good, efficient programs.

        Indeed. Also, Rust is far too complicated with a number of paradigms thrown in and OO being half-ass. That whole thing screams "I am different for the sake of being differen!". Yes, I could work in it and use all of its features. But I am hardly an average coder.

      • C will always, ALWAYS just open the fucking pod bay doors when you tell it to.

        Good analogy. Always doing something means invariably someone will ask and the entire ship will be emptied into the vacuum of space. If we had perfect humans then C would be great. We don't. Sometimes when someone says "Open the pod bay doors" the answer should be "No, they are interlocked for the safety of everyone".

        • by Uecker ( 1842596 )

          True, the question is whether this should not better be a level of verification on top of C.

      • Rust just has too much inherent friction to ever be as elegant or useful.

        Most programmers today can't even recognize elegance, let alone produce it. Most programmers prefer whatever language they learned while young.

      • C treats you like an adult. Which selects for things like double-free exploits
        Like https://securityonline.info/po... [securityonline.info] , which, if C had stopped the developer from adding the memory pointer to two different lists, and freeing it from both, the root exploit wouldn't have existed.

        Unless of course, the developers who maintain netfilter aren't adults.

        Personally, I use C over Rust, because it's easier.

    • by dfghjk ( 711126 )

      "(and "work" should always include "secure".)"

      Should it? Should security be enforced internally or externally? What if the program has no external connectivity?

      • by Entrope ( 68843 )

        "(and "work" should always include "secure".)"

        Should it? Should security be enforced internally or externally?

        Yes, and (unsurprisingly) it depends on what the program does.

        What if the program has no external connectivity?

        If the system has no external connectivity (or it secures the program against unauthorized access), all inputs are generated by the data owners, all users have equivalent access to all the data the program can access, there are no concerns about side channel information leaks, and incorrect or incomplete behavior are not considered "security" concerns (under the rubrics of integrity and availability, respectively), then the program can probably d

        • by KGIII ( 973947 )

          If the system has no external connectivity (or it secures the program against unauthorized access), all inputs are generated by the data owners, all users have equivalent access to all the data the program can access, there are no concerns about side channel information leaks, and incorrect or incomplete behavior are not considered "security" concerns (under the rubrics of integrity and availability, respectively), then the program can probably disregard security. The second and third items are uncommon in organizational environments.

          While interesting, that seems more theoretical than reasonable.

          I can't think of a situation where I'd trust those caveats to be a guarantee.

          And, in places where that is a guarantee, they're going to still want security to be built into the application. At least I'd hope so.

          But, yeah... I don't think I'd ever trust such a system to that degree. There are humans involved. Someone will get frustrated with that system and it won't be long before you'll find someone has figured out a way to sneak in their cell p

          • by vakuona ( 788200 )

            On top of that, the use of software evolves, and software that might not have been expected to be internet facing may one day end up on the internet, security issues and all. So it is good practice to ensure software is secure by default, even if it is being used on an air-gapped computer in the middle of some remote desert.

    • by gweihir ( 88907 )

      Also, the first rule of optimization: Don't do it.

  • ffmpeg (Score:4, Interesting)

    by backslashdot ( 95548 ) on Sunday May 18, 2025 @02:01PM (#65385295)

    They are the ones to talk. I mean, if any group must shut the fuck up in the Rust vs. C debate it's ffmpeg. They are one of the top reasons Rust had to be invented. Have they no shame? Reference: https://www.cve.org/CVERecord/... [cve.org]

  • by BrendaEM ( 871664 ) on Sunday May 18, 2025 @02:04PM (#65385303) Homepage
    Please, please replace everything with Rust : (
  • by ZipNada ( 10152669 ) on Sunday May 18, 2025 @02:19PM (#65385337)

    The original code architecture was optimized for C. They used "the c2rust tool" to convert it initially, and then worked from there to optimize. Maybe the original overall design wasn't conducive to Rust.

    Also, according to the article, the original C code did no bounds checking and no initialization of buffers. Doing that takes time.

    "our profiling now indicates that the remaining overhead is spread roughly evenly across the largest, most complex functions in rav1d", sounds like no low-hanging fruit remains to be picked.

    • Also, according to the article, the original C code did no bounds checking and no initialization of buffers. Doing that takes time.

      Which they should have fixed/added to the original code, for no other reason than to make it better -- and then do the runtime comparison w/the Rust version.

      • by Uecker ( 1842596 )

        This assumes the missing initialization or bounds check is a bug, and not simply redundant.

        • This assumes the missing initialization or bounds check is a bug, and not simply redundant.

          Sure, although things can easily be thought redundant until some clever person makes it a bug ...

          • by Uecker ( 1842596 )

            Maybe, but this does not imply that not having redundant checks is an issue with the original code, which was your comment.

    • From TFA that doesn't sound like the problem.

      The initial pass generates non idiomatic rust which is mostly unsafe pointer dereferences, so it's semantically very close to C. Even that was a bit less efficient. My suspicion is that the Rust compiler front end is somewhat less mature than the C one.

      It doesn't feel like there is an inherent reason for it to be slower: the code is instructing the compiler to do basically the same stuff in the same way and with the same optimizer. I reckon it's not doing as good

    • by gweihir ( 88907 )

      Also, according to the article, the original C code did no bounds checking and no initialization of buffers. Doing that takes time.

      Which pretty much means they started with crap C code...

  • I read how to submit code, read the "rules", and I am confused about a lot of things. First, the contest ends at the end of the year, possibly plus one month. The award will be given out on some kind of a percentage basis on up to 10 people. What I am confused about is do they want people to submit incremental improvements? Will programmers get feedback on their code like they are almost employees? Will they merge your improvements with other peoples improvements between now and the end of the ye
    • The way I am reading this, they want a lot of people to act like one employee for over 6 months, and pay them maybe $1000. They will test incremental improvements in the code over that time, and give feedback. My "Scam" alert is going off in my mind.
  • 'Rust is So Good You Can Get Paid $20K to Make It as Fast as C'

    What has "rust is so good" got to do with the rest of the sentence?

    Look, I like the idea of rust... but these bizarre masturbatory declarations sometimes seem ubiquitous in rust-land, and I believe they are the main thing that puts people off it.

    • by PPH ( 736903 ) on Sunday May 18, 2025 @02:51PM (#65385409)

      They forgot the <sarcasm></sarcasm> tags.

    • by gweihir ( 88907 )

      ...but these bizarre masturbatory declarations sometimes seem ubiquitous in rust-land, and I believe they are the main thing that puts people off it.

      Indeed. The bizarre, cult-like community alone is a good reason to stay away.

      • by kertaamo ( 16100 )

        As a long time user of many languages, since 1980 in fact, as a user of Rust for the last five years and a follower of Rust forums and other channels I have to say I don't see a "cult like" community among Rust folks anymore than enthusiasts of any other language or technology. I don't see any more "bizarre" people there than anywhere else in society.

        What I do see is this stupid, unfounded, and insulting characterisation being thrown at Rust devs and users all the time. What do you do that?

  • Everything eventually decays to Rust [9cache.com].

  • Both sorts suck (Score:2, Interesting)

    by Anonymous Coward

    Obsessive Rust evangelists? Very annoying.
    Obsessive Rust haters? Equally annoying.

    A plague on both their houses.

    That is all.

  • Rust is so good, it would have caught pretty much all of the ffmpeg CVE's at compile time. From buffer overflows, to double frees, to null pointer dereferences, and use-after-free vulnerabilities.
    Just have a look through the hundreds of examples over on cve.org , they're mostly doing bad things with pointers or memory management.

Talent does what it can. Genius does what it must. You do what you get paid to do.

Working...