News for hackers. Stuff that matters.
Re:Branchless Rust: Making a Filter 4x Faster by Removing an If by llama_drama on Thursday August 06, 2026 @07:25AM (#49195236)
Branchless code can indeed sometimes be slower than conventional one, but in this particular case, the article comes to the wrong conclusion. At a 1% kept, the branchless version is slower because it pays the cost of zero-initializing 8 MB of memory when allocating the Vec. This can be easily demonstrated by comparing it with a version that allocates uninitialized memory.
Re:Branchless Rust: Making a Filter 4x Faster by Removing an If by rabiescow on Thursday August 06, 2026 @03:40PM (#49201366)
Did you read the article? The author was trying to even out the test cases and successfully did so. He stated that the idiomatic code was faster for the 1 % as you can see by quote below:

  The worst case became almost 4 times faster. And look how flat the branchless column   is: the running time does not depend on the data anymore, exactly as we wanted.

  Notice the price we paid though. At 1% kept the idiomatic version wins, because an almost always correctly predicted branch is nearly free, while the branchless version always pays for one million writes. Branchless code is not faster in general: it trades the best case for the worst case.