memorysafety / memorysafety/rav1d
perf: `fn Rav1dFrameData::{seq,frame}_hdr`: Remove `.unwrap()` and `Arc::deref` overhead
Nobody has claimed this yet.
- Dominant language
- Assembly
- Stars
- 643
- Forks
- 81
- PR merge metrics
- No merged PRs in 30d
Description
I'm not a fan of these methods. They hide the cost of the .unwrap() and Arc derefs, which we really don't want to be doing in any tight loops like there might be in fn decode_b. Two solutions are:
-
Most of the data accessed through things like
frame_hdrare smallCopyable fields. These we can justCopyout at the beginning and use directly. For larger fields like arrays, such asgmv, we can pay the cost there. -
Remove the
frame_hdrandseq_hdrfields fromRav1dFrameData. If&Rav1dFrameDatacan be passed all the way down, then I thinkframe_hdrandseq_hdrcan, and then we can do the.unwrap()andArcderef only once at the beginning, and it very nicely untangles things.
See https://github.com/memorysafety/rav1d/pull/748#discussion_r1491949073.
However, this is just for perf, and the solution is not exceedingly simple, so we can save it for later.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading Rav1dFrameData and the fn decode_b call path, focusing on its frame_hdr and seq_hdr access. Compare the two proposed approaches in the issue and trace where &Rav1dFrameData can be passed further down. Done means the chosen design removes repeated unwrap and Arc dereference overhead from tight loops without changing decoding behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend, performance
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100