The input/output complexity of sorting and related problems
Communications of the ACM
Computer architecture: a quantitative approach
Computer architecture: a quantitative approach
Software—Practice & Experience
AlphaSort: a RISC machine sort
SIGMOD '94 Proceedings of the 1994 ACM SIGMOD international conference on Management of data
A super scalar sort algorithm for RISC processors
SIGMOD '96 Proceedings of the 1996 ACM SIGMOD international conference on Management of data
The influence of caches on the performance of heaps
Journal of Experimental Algorithmics (JEA)
The art of computer programming, volume 1 (3rd ed.): fundamental algorithms
The art of computer programming, volume 1 (3rd ed.): fundamental algorithms
The art of computer programming, volume 3: (2nd ed.) sorting and searching
The art of computer programming, volume 3: (2nd ed.) sorting and searching
The influence of caches on the performance of sorting
SODA '97 Proceedings of the eighth annual ACM-SIAM symposium on Discrete algorithms
Sorting on Electronic Computer Systems
Journal of the ACM (JACM)
Implementing Quicksort programs
Communications of the ACM
A high-speed sorting procedure
Communications of the ACM
Improving memory performance of sorting algorithms
Journal of Experimental Algorithmics (JEA)
Algorithms in C
Branch Effect Reduction Techniques
Computer
Nordic Journal of Computing
FOCS '99 Proceedings of the 40th Annual Symposium on Foundations of Computer Science
Caches and algorithms
Efficient sorting using registers and caches
Journal of Experimental Algorithmics (JEA)
Adapting Radix Sort to the Memory Hierarchy
Journal of Experimental Algorithmics (JEA)
Optimizing Sorting with Genetic Algorithms
Proceedings of the international symposium on Code generation and optimization
Engineering a cache-oblivious sorting algorithm
Journal of Experimental Algorithmics (JEA)
How branch mispredictions affect quicksort
ESA'06 Proceedings of the 14th conference on Annual European Symposium - Volume 14
Tradeoffs between branch mispredictions and comparisons for sorting algorithms
WADS'05 Proceedings of the 9th international conference on Algorithms and Data Structures
Branch mispredictions don't affect mergesort
SEA'12 Proceedings of the 11th international conference on Experimental Algorithms
Lean programs, branch mispredictions, and sorting
FUN'12 Proceedings of the 6th international conference on Fun with Algorithms
Hi-index | 0.00 |
Sorting is one of the most important and well-studied problems in computer science. Many good algorithms are known which offer various trade-offs in efficiency, simplicity, memory use, and other factors. However, these algorithms do not take into account features of modern computer architectures that significantly influence performance. Caches and branch predictors are two such features and, while there has been a significant amount of research into the cache performance of general purpose sorting algorithms, there has been little research on their branch prediction properties. In this paper, we empirically examine the behavior of the branches in all the most common sorting algorithms. We also consider the interaction of cache optimization on the predictability of the branches in these algorithms. We find insertion sort to have the fewest branch mispredictions of any comparison-based sorting algorithm, that bubble and shaker sort operate in a fashion that makes their branches highly unpredictable, that the unpredictability of shellsort's branches improves its caching behavior, and that several cache optimizations have little effect on mergesort's branch mispredictions. We find also that optimizations to quicksort, for example the choice of pivot, have a strong influence on the predictability of its branches. We point out a simple way of removing branch instructions from a classic heapsort implementation and also show that unrolling a loop in a cache-optimized heapsort implementation improves the predicitability of its branches. Finally, we note that when sorting random data two-level adaptive branch predictors are usually no better than simpler bimodal predictors. This is despite the fact that two-level adaptive predictors are almost always superior to bimodal predictors, in general.