I was just recently going through some old episodes from Software Engineering Radio when I came across this one episode featuring Casey Muratori, where he goes through some of his thoughts around his video from February 2023, titled "‘Clean’ Code, Horrible Performance". I was actually already aware of the video by this time, but listening through the episode gave me an itch to see these concepts in my reality, experiment them by myself.
So the problem discovered is that the compiler can’t optimize the loops by unrolling them (due to floating point issues?). The proposed solution is to unroll the loop manually.
But wouldn’t it be much cleaner and more performant to just have a macro like
#![allow lossy floating point optimizations]
and let the compiler figure out the rest?Compilers exist to compile and optimize things. Manually unrolling loops might improve performance on one machine, but completely break the program on another. It’s much safer and more performant in the long term to allow the compiler the leeway to optimize things the optimal way.