Cache-friendly binary search
bannalia.blogspot.com
Cache-friendly binary search
1–10 of 14 posts
Re: Cache-friendly binary search
#2http://www.pvk.ca/Blog/2012/07/30/binary-search-is-a-patholo...
Re: Cache-friendly binary search
#3http://supertech.csail.mit.edu/cacheObliviousBTree.html
More generally: in the last 10-15 years there has been a lot of work on developing algorithms that are compatible with caching, but which do not need to be tuned to the details of a particular cache hierarchy on which they run. For more info, see
Demaine, Erik D. "Cache-Oblivious Algorithms and Data Structures." http://erikdemaine.org/papers/BRICS2002/paper.pdf
Erik Demaine's 6.046 lectures on this topic are available on YouTube: https://www.youtube.com/watch?v=cJOHERGcGm4 and https://www.youtube.com/watch?v=zjUDy6a5vx4
One cache-oblivious dynamic tree structure is also due to Demaine: http://erikdemaine.org/papers/CacheObliviousBTrees_SICOMP/
Re: Cache-friendly binary search
#4Re: Cache-friendly binary search
#5I also really liked the nice package there for testing it out yourself, creating results package and clear email instructions for contributing the results.
Is there any good way of running these kinds of experiments on a variety of hardware possibly with other people's help?
Re: Cache-friendly binary search
#6A "simple" memory layout for cache friendliness (assuming you don't have to do updates on your tree; there exists a more complicated cache-friendly dynamic tree structure, too) is a recursive van Emde Boas layout. This memory layout will achieve performance no more than a (small) constant multiple worse than an omniscent cache in terms of the number of cache misses, and it requires almost no tuning to work in any cac…
Re: Cache-friendly binary search
#7A "simple" memory layout for cache friendliness (assuming you don't have to do updates on your tree; there exists a more complicated cache-friendly dynamic tree structure, too) is a recursive van Emde Boas layout. This memory layout will achieve performance no more than a (small) constant multiple worse than an omniscent cache in terms of the number of cache misses, and it requires almost no tuning to work in any cac…
Re: Cache-friendly binary search
#8A "simple" memory layout for cache friendliness (assuming you don't have to do updates on your tree; there exists a more complicated cache-friendly dynamic tree structure, too) is a recursive van Emde Boas layout. This memory layout will achieve performance no more than a (small) constant multiple worse than an omniscent cache in terms of the number of cache misses, and it requires almost no tuning to work in any cac…
Re: Cache-friendly binary search
#9https://people.mpi-inf.mpg.de/~rgemulla/publications/schlege...
As SSE/AVX registers get wider and wider you might as well compare an entire cache line (or two) at a time. But the overhead of building the level order k-tree means you need to do a whole lot of lookups for each insert... so it doesn't apply to that many problems. Unless you're building a search engine. Then it applies a lot.
Re: Cache-friendly binary search
#10We tend to end up comparing keys that are much smaller than the cache lines - and the memory access takes so long compared to the actual calculation that you may as well check everything in the cacheline "while you're at it".
Which ends up meaning that in practice, you may as well do a k-ary search.
I wonder how much, if any, this can be improved by prefetching the indexes you might access next step?