Advertisement

How Branch Mispredictions Affect Quicksort

  • Kanela Kaligosi
  • Peter Sanders
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4168)

Abstract

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.

Keywords

Prediction Scheme Sorting Algorithm Static Predictor Branch Prediction Branch Instruction 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Hoare, C.A.R.: Algorithm 64: Quicksort. Commun. ACM 4(7), 321 (1961)CrossRefGoogle Scholar
  2. 2.
    Knuth, D.E.: The Art of Computer Programming—Sorting and Searching, vol. 3. Addison-Wesley, Reading (1973)Google Scholar
  3. 3.
    Martínez, C., Roura, S.: Optimal sampling strategies in Quicksort and Quickselect. SIAM Journal on Computing 31(3), 683–705 (2002)CrossRefGoogle Scholar
  4. 4.
    Sanders, P., Winkel, S.: Super scalar sample sort. In: Albers, S., Radzik, T. (eds.) ESA 2004. LNCS, vol. 3221, pp. 784–796. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  5. 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
  6. 6.
    Brodal, G.S., Moruz, G.: Tradeoffs between branch mispredictions and comparisons for sorting algorithms. In: Dehne, F., López-Ortiz, A., Sack, J.-R. (eds.) WADS 2005. LNCS, vol. 3608, pp. 385–395. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  7. 7.
    Patterson, D.A., Hennessy, J.L.: Computer Architecture: A Quantitative Approach, 3rd edn. Morgan Kaufmann, San Francisco (2003)Google Scholar
  8. 8.
    Sedgewick, R.: Algorithms, 2nd edn. Addison-Wesley Longman Publishing Co., Amsterdam (1988)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2006

Authors and Affiliations

  • Kanela Kaligosi
    • 1
  • Peter Sanders
    • 2
  1. 1.Max Planck Institut für InformatikSaarbrückenGermany
  2. 2.Universität KarlsruheGermany

Personalised recommendations