Back to feed
Dev.to
Dev.to
5/11/2026
CPU branch prediction is wrong

CPU branch prediction is wrong

Original: Your CPU Is Guessing the Future, and Wrong 5% of the Time

Short summary

Modern CPUs use branch prediction to speculatively execute conditional branches with ~95% average accuracy—but that headline papers over where costs actually live. Mispredictions (13–20 cycle penalties) concentrate on unpredictable code paths: indirect calls, pointer chasing, data-dependent comparisons. The real engineering challenge is profiling actual misses, not relying on aggregate accuracy, while weighing speculative execution's performance benefits against growing security vulnerabilities.

  • 95% branch prediction accuracy is a workload-averaged number dominated by predictable hot paths, not the cold paths where misses cost real cycles
  • Misprediction penalties (13–20 cycles at modern frequencies) hit hardest on inherently unpredictable branches in dynamic dispatch and data-dependent code
  • Speculative execution enables performance but creates exploitable security boundaries; mitigations asymmetrically impact different CPU vendors (AMD ≈5%, Intel ≈27% loss)

Generated with AI, which can make mistakes.

Is this a good recommendation for you?

Comments

Failed to load comments. Please try again.

Explore more