How Branch Mispredictions Affect Quicksort
We explain the counterintuitive observation that finding “good” pivots (close to the median of the array to be partitioned) may not improve performance of quicksort. Indeed, an intentionally skewed pivot improves performance. The reason is that while the instruction count decreases with the quality of the pivot, the likelihood that the direction of a branch is mispredicted also goes up. We analyze the effect of simple branch prediction schemes and measure the effects on real hardware.
KeywordsPrediction Scheme Sorting Algorithm Static Predictor Branch Prediction Branch Instruction
Unable to display preview. Download preview PDF.
- 2.Knuth, D.E.: The Art of Computer Programming—Sorting and Searching, vol. 3. Addison-Wesley, Reading (1973)Google Scholar
- 5.Brodal, G.S., Fagerberg, R., Moruz, G.: On the adaptiveness of quicksort. In: Workshop on Algorithm Engineering & Experiments, pp. 130–149. SIAM, Philadelphia (2005)Google Scholar
- 7.Patterson, D.A., Hennessy, J.L.: Computer Architecture: A Quantitative Approach, 3rd edn. Morgan Kaufmann, San Francisco (2003)Google Scholar
- 8.Sedgewick, R.: Algorithms, 2nd edn. Addison-Wesley Longman Publishing Co., Amsterdam (1988)Google Scholar