4 ms·
The big advantage of the Eytzinger layout actually comes into play when your binary search isn't branch-free. In that case, the CPU will speculate loads reason
by atq2119 4y ago
The big advantage of the Eytzinger layout actually comes into play when your binary search isn't branch-free.
In that case, the CPU will speculate loads reasonably far ahead, and because both choices tend to be in the same cacheline, this prefetch is rarely wasted.
In other words, the big win isn't about reducing the number of cacheline fetched, it's about reducing the effective latency of those fetches.
That said, using a similar layout with higher fan-out and SIMD ops doesn't benefit from this effect and is probably still better.
- srcreigh 4y agoI think effective latency and reducing the number of cache lines is probably the exact same thing. The point is instead of fetching 5 cache lines to get to the 5th layer of the tree from memory, you fetch just 2 and access the mega root node via cache.