4 ms·
Branch prediction is pretty fundamental to CPU performance; unless we want much slower CPUs it’s necessary. Although it’s interesting to think about how softwa
by mikebenfield 4y ago
Branch prediction is pretty fundamental to CPU performance; unless we want much slower CPUs it’s necessary.
Although it’s interesting to think about how software could help with branch prediction, the simple answer about the kernel thing is that software is the wrong place in the architecture for branch prediction to happen. Maybe there’s some crazy alternative way things could be done, but in anything like the current computing model branch prediction has to happen in hardware.
- Izkata 4y ago> Maybe there’s some crazy alternative way things could be done "Branchless programming" is an umbrella term for techniques in existing programming languages to avoid branches.
- astrange 4y agoIt almost always doesn’t work; if a branch can eliminate a single uncached memory read you’d want to keep that branch. It’s mostly used for things like min/max operations in cases when you don’t have cmov. Or bitwise SIMD programming.