Hacker News new | ask | show | jobs
by mlindner 4072 days ago
x86 branch predictors are not 60% correct... Any decent branch predictor is over 90% correct and I believe modern ones are over 96% correct.
2 comments

That's completely dependent on your algorithms.

Branch prediction in some search in a hash will fail 50% of the time, however it's done. Branch prediction on a long for loop was more than 99% correct by the end of the 90's already.

Intel claims their prediction algorithms are over 96% correct on an average program, whatever that beast is. (To be fair, you'll find a definition for it at their papers. That's a perfectly legit claim, it just does not mean what you think it means.)

If your data is unpredictable, the branchless instructions save time wasted trying to predict it. If you're doing any kind of data compression, either your compressed data is unpredictable or it's not compressed enough!

Getting rid of branching in the unimportant parts of your program is good too; saves space in the cache for important branch predictions.

This is the kind of thing where it's not worth doing by hand, but I don't think compilers really do it either…