Branch prediction is like that friend who finishes your sentences but gets it wrong sometimes. The CPU speculatively executes instructions down a predicted path, and when it realizes it took the wrong branch, it has to discard all that work and start over. Embarrassing for the CPU, sure, but at least nobody remembers, right?
Wrong. The cache is sitting there like "Yeah, I saw everything." Even though the CPU discarded those speculative results, the cache already loaded data from those incorrect instructions into its memory hierarchy. It's like trying to unsee something—too late, buddy. The cache has receipts.
Fun fact: This is exactly how Spectre and Meltdown exploits work. Attackers use the cache's "memory" of speculative execution to leak sensitive data by measuring timing differences. Your CPU's optimization became a security nightmare because cache never forgets. It's basically the NSA of computer components.
AI
AWS
Agile
Algorithms
Android
Apple
Bash
C++