$20K Bounty Offered for Optimizing Rust Code in Rav1d AV1 Decoder
113 comments
·May 14, 2025pizza234
StopDisinfo910
> Based on the article, it seems that with highly complex logic, safety does come at the cost of raw performance, and it can be very hard to compensate (withing the safety requirements).
In Rust. These are Rust issues, not issues with safety in general.
The issue with bound checks for exemple is entirely avoidable if you prove that all your calls are within bounds before compiling, same thing for partial initialization.
The core issue is that the strategies Rust adopts to ensure memory safety are neither a panacea nor necessarily the right solution in every case. That being said, I think it's a very nice idea to try to write a decoder in Rust and have a bounty for optimization. Rust is popular so work on producing fast and safe Rust is good.
pizza234
> The issue with bound checks for exemple is entirely avoidable if you prove that all your calls are within bounds before compiling, same thing for partial initialization.
The situation is more nuanced. The article dedicates a section to it:
> The general idea in eliding unnecessary bounds checks was that we needed to expose as much information about indices and slice bounds to the compiler as possible. We found many cases where we knew, from global context, that indices were guaranteed to be in range, but the compiler could not infer this only from local information (even with inlining). Most of our effort to elide bounds checks went into exposing additional context to buffer accesses.
(extensive information given in that section)
immibis
I think the comment you replied to is about a different approach: writing the algorithm in assembly or C, and then proving it doesn't access anything out of bounds.
This is the WUFFS approach, for example. Formal verification, while very cool, is extremely tedious, which is why more practical languages try to find compromise rules that are simpler to implement, while also not too limiting.
HPsquared
If there isn't already a name for this compile-time safety checking in Rust, I vote we call it "passivation".
HideousKojima
>The issue with bound checks for exemple is entirely avoidable if you prove that all your calls are within bounds before compiling, same thing for partial initialization.
You can't always know the bounds at compile time, though.
anon-3988
If the compiler is smart enough and the code is written in the right way, the compiler should be able to omit a lot of bounds check. This is much easier to achieve in Rust (safely) because of noaliasing by default.
steveklabnik
> Based on the article, it seems that with highly complex logic, safety does come at the cost of raw performance
You cannot draw general conclusions by the experiences of one project one time. There are too many confounding factors. There are also projects who have experienced the opposite.
null
Ragnarork
$20K sounds very low for the effort and expertise that are demanded here in my opinion. It would be quite a steal to bring this to the same level as the state of the art (which, correct me if I'm wrong, but I believe is dav1d?) for only that sum.
marxism
My reading is this isn't for random engineers but experienced performance engineers with optimized toolchains who can tackle this efficiently. For someone with the right setup, this is likely straightforward work.
It's similar to job descriptions written for specific candidates they plan to hire. The question shouldn't be "why is this bounty so low?" but "what toolchain makes $20K reasonable for someone?"
Performance work in my experience has been largely organizational friction: running projects in various conditions, collecting evidence maintainers accept, maximizing that limited slice of attention people give my CLs, getting compiler improvements merged. These coordination tasks have become much easier to automate with LLMs (e.g., analyzing maintainer comments to understand cryptic 1 line feedback, what are they actually looking for, what do they mean).
My guess is there's an engineer who's either optimized their feedback cycle to under an hour through specialized tooling (more arrows) or is much better at finding the right signal the first time (more wood). I'd like to understand what tools enable that efficiency.
jebarker
I assume they're hoping to nerd snipe someone
viraptor
And they did it well. If I was still a student without a family, I'd sink an unreasonable number of nights into this.
null
burjui
It's more likely they will end up shotgunning sloppy AI PRs.
wslh
Yes, but you left many excellent candidates.
PhilipRoman
Purchasing power parity strikes again... There are places in EU where that is 6 to 12 months of pay for a programmer.
regularjack
Programmers in EU who have the skills to do this type of work can likely charge much more than that for 6 to 12 months.
_ache_
Absolutely. If you don't know dav1d, it's easy to overlook the complexity here.
There is a reason for this sentence: > « The dav1d and rav1d decoders share the exact same low-level assembly code optimizations—you cannot modify this assembly ».
So, it, kind of, makes the work easier, but it stills very complex I think.
Zenbit_UX
The reason for that disclaimer should be obvious, any improvements to the assembly code would also benefit dav1d in c, therefore the rust code still remains worse off by comparison.
I’m sure both the dav1d and dav1d communities would appreciate improvements to the assembly code, but the goal of this contest is to improve the rust implementation only.
irf1
Anyone who wants to offer a bounty on GitHub can try https://algora.io
It’s an open source platform (built in Elixir) for sharing bounties, contract work and full-time jobs with open source engineers
I’m one of the founders, feel free to reach out ioannis@algora.io
klaussilveira
I maintain an open-source project that could use some new contributors. We have bounties ranging from $50 to $100. Would that be attractive in this platform?
irf1
Sure give it a try! If your project is cool I bet people will be eager to contribute regardless.
jebarker
I'd love it if someone started Kaggle for software optimization
rvz
The sort of bounty + interview question I would ask when I'm really looking for those who will actually use such optimal algorithms in practice where it directly applies.
Which is exactly this for video decoders.
In fact, a bounty will show us who really is serious or not and even some interviewers don't have a clue why they ask for 'optimal algorithms' in the first place. Maybe just to show off that they Googled or used ChatGPT for the answer before the interview.
Well, you can't do it for this one. The one who improves this and can explain their changes will have a impressive show of expertise which puts lots of so-called 'SWEs' to shame.
hluska
Software is a huge field. There’s no reason any developer should feel shame because they can’t do something. The field is far too big.
nomel
> The one who improves this and can explain their changes will have a impressive show of expertise which puts lots of so-called 'SWEs' to shame.
Software is a means of automation that's used in every industry of man. Someone not knowing a particular, very specific, problem space isn't something to be ashamed of.
irf1
you can do exactly that with Algora.io
0x000xca0xfe
This would be utterly fantastic.
minraws
Welp,
> The contest is open to individuals or teams of individuals who are legal residents or citizens of the United States, United Kingdom, European Union, Canada, New Zealand, or Australia.
So most countries where putting in the effort would actually be worth the bounty offered is a no go...
I understand.
jaoane
Can’t talk about the other countries but $20K is a shitload of money in many countries of the EU.
Suppafly
>Can’t talk about the other countries but $20K is a shitload of money in many countries of the EU.
It's a decent bonus in large parts of the US too. Not everyone on HN works for a FAANG company.
minraws
Is it enough for this project though? I have worked on optimization projects, and have been hired as the Performance person, making well over 5K US a month in a startup working on optimization stuff, in a 3rd world(read: one of the two largest asian) country...
Largely because optimizing the last 10% in such projects is extremely labour intensive and niche work.
Either way this feels like atleast 4-5 months of full time work minimum...
Creating a bounty which is essentially a zero sum competition and not including folks from countries where 20k can be living annual wage...
Means you are essentially excluding most folks who are working full time.
And honestly if someone can wrap this up in a couple months as a side hustle. And if they feel like 20K was more than worth their time..
Then not to argue but they are significantly under paid.
And if I had a company, I would definitely like to hire them. Even at 15-20K a month...
pabs3
More resources for getting paid to do open source:
canucker2016
from https://www.memorysafety.org/blog/rav1d-performance-optimiza...
rav1d is transpiled c-to-rust version of dav1d, compiled using Clang18 for dav1d and relevant Clang18-LLVM backend code for rustc.
Measurements showed rav1d was 3.8% slower than dav1d. Hacking up a rustc to turn off bounds checking showed rav1d-no-bounds-check was 3% slower than dav1d.
So rustc bounds checking resulted in <1% total slowdown from dav1d.
Another theory about slowdown was due to overflow checking with signed arithmetic. Further tests showed only isolated incidents of slowdown due to overflow arithmetic checking.
According to perf counters, rav1d executed 7% more instructions than dav1d. Approximately 2% of 7% is due to bounds checking.
More info about subtle interactions with changing transpiled code to idiomatic Rust in the article.
"After applying the optimization techniques discussed here (and more), we have reduced performance overhead from a peak of about 11% when we started optimizing the safe Rust implementation in earnest to under 6% now on x86_64. We believe there is still room for further improvement, both in how the compiler optimizes Rust and in our implementation details. This will necessarily be a process of small, incremental improvements, as our profiling now indicates that the remaining overhead is spread roughly evenly across the largest, most complex functions in rav1d."
burjui
> rav1d is transpiled c-to-rust version of dav1d
Sounds like a bad way to port. Completely different languages. It took me some time to learn that one cannot simply write C code in Rust and expect the result to be any good. Should've started from scratch.
typedef_struct
Confirms Rust is about where I thought it was. In a strange niche where you don’t need 100% the performance of C, but the 90% you get from a managed language isn’t enough. And you can’t run on the GPU.
dblohm7
I had always kind of hoped that somebody would try to build production decoders using something like Halide. [1]
bArray
For the purpose of an experiment, I would love to see $20k also offered to eek out more performance on the dav1d decoder, otherwise this is just a measure of how much money people are willing to pour into optimisations.
degamad
There is already significant investment from AOM, Videolan, and FFMPEG funding the development of dav1d. Is there a reason that that investment is not relevant?
From what I can tell, way more than $20k has been invested into dav1d, and that investment has generated many performance optimisations already. Ostensibly, that's what this rav1d bounty is competing with.
bArray
> Is there a reason that that investment is not relevant?
I wasn't aware of it, in that case this could be a more interesting comparison.
> From what I can tell, way more than $20k has been invested into dav1d, and that investment has generated many performance optimisations already. Ostensibly, that's what this rav1d bounty is competing with.
Was rav1d a port of dav1d or developed from scratch?
Zenbit_UX
Your comment reads like the school room dilemma of if your mom gives you cookies to share with your friends at lunch she better bring enough for everyone.
This is being done to prove a point, that rust is just as efficient as c while being memory safe.
Your idea is misaligned with the goals of the contest and more a moral complaint on “fairness”. Where do you get this notion that any entity offering their own funds in a contest needs to distribute it evenly?
bArray
Your reply reads as if you have skin in this game and are for some unknown reason offended by the idea of a fair test.
> This is being done to prove a point, that rust is just as efficient as c while being memory safe.
I understand that, but it could just end up being a measure of how much money we are willing to pour into libraries. If you start putting money in to any language, you should see efficiency increase and bugs decrease.
A nice result would be them being about the same speed, but Rust offering greater protections.
> Your idea is misaligned with the goals of the contest and more a moral complaint on “fairness”. Where do you get this notion that any entity offering their own funds in a contest needs to distribute it evenly?
It was an intrigue, not a demand.
fwip
The official rules include this interesting bit:
> Solutions must be in either rav1d itself, the Rust compiler (inclusive of llvm), or the Rust standard library.
dhruv3006
[flagged]
The related post on performance optimization is extremely interesting, in particular, the considerations drawn while moving from the unsafe ported code to safe¹:
> The first performance issue we hit was dynamic dispatch to assembly, as these calls are very hot. We then began adding inner mutability when necessary but had to carefully avoid contention. We found as we removed pointers and transitioned to safe Rust types that bounds checks increasingly became a larger factor. Buffer and structure initialization was also an issue as we migrated to safe, owned Rust types.
Based on their conclusions², each of those issues amounts to a few percentage points (total: 11%).
Based on the article, it seems that with highly complex logic, safety does come at the cost of raw performance, and it can be very hard to compensate (withing the safety requirements).
[¹]: https://www.memorysafety.org/blog/rav1d-performance-optimiza...
[²]: https://www.memorysafety.org/blog/rav1d-performance-optimiza...