The related post on performance optimization is extremely interesting, in particular, the considerations drawn while moving from the unsafe ported code to safe¹:<p>> 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.<p>Based on their conclusions², each of those issues amounts to a few percentage points (total: 11%).<p>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).<p>[¹]: <a href="https://www.memorysafety.org/blog/rav1d-performance-optimization/#optimization-process" rel="nofollow">https://www.memorysafety.org/blog/rav1d-performance-optimiza...</a><p>[²]: <a href="https://www.memorysafety.org/blog/rav1d-performance-optimization/#current-state" rel="nofollow">https://www.memorysafety.org/blog/rav1d-performance-optimiza...</a>