3 ms·
> last time I checked a cpu documentation they had a simple rule that branches are always taken, that would be easy for the compiler to code order first. Was t
by School-Cotton 11mo ago
> last time I checked a cpu documentation they had a simple rule that branches are always taken, that would be easy for the compiler to code order first.
Was that in the 80s? Modern performant CPUs all use dynamic branch prediction.
I’m not really sure I understand the “where does it get the memory” point. Yes, this requires some amount of memory per tracked branch. This memory is hardwired into the CPU, just like all the other memory a CPU needs to do its job (registers, L1 cache, TLB, various in-flight instruction state, etc.)
- bluGill 11mo agoover the 15 million lines of code I maintain there are a lot of branches. the cpu can track the most common ones but as soon as the code spills out of cache where does that memory come from?
- School-Cotton 11mo agoIt doesn’t track all of them, it’s a cache. The ones that were hit long enough ago get evicted, and then if you ever hit them again the processor will indeed have to fall back to a naive static prediction strategy with a high miss probability.
- bluGill 11mo agoThanks, that makes sense now