Good Predictions Are Worth a Few Comparisons

Authors Nicolas Auger, Cyril Nicaud, Carine Pivoteau

Thumbnail PDF


  • Filesize: 2.04 MB
  • 14 pages

Document Identifiers

Author Details

Nicolas Auger
Cyril Nicaud
Carine Pivoteau

Cite AsGet BibTex

Nicolas Auger, Cyril Nicaud, and Carine Pivoteau. Good Predictions Are Worth a Few Comparisons. In 33rd Symposium on Theoretical Aspects of Computer Science (STACS 2016). Leibniz International Proceedings in Informatics (LIPIcs), Volume 47, pp. 12:1-12:14, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2016)


Most modern processors are heavily parallelized and use predictors to guess the outcome of conditional branches, in order to avoid costly stalls in their pipelines. We propose predictor-friendly versions of two classical algorithms: exponentiation by squaring and binary search in a sorted array. These variants result in less mispredictions on average, at the cost of an increased number of operations. These theoretical results are supported by experimentations that show that our algorithms perform significantly better than the standard ones, for primitive data types.
  • branch misses
  • binary search
  • exponentiation by squaring
  • Markov chains


  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    PDF Downloads


  1. Paul Biggar, Nicholas Nash, Kevin Williams, and David Gregg. An experimental study of sorting and branch prediction. Journal of Experimental Algorithmics, 12:1, June 2008. URL:
  2. Gerth Stølting Brodal, Rolf Fagerberg, and Gabriel Moruz. On the adaptiveness of quicksort. ACM Journal of Experimental Algorithmics, 12, 2008. URL:
  3. Gerth Stølting Brodal and Gabriel Moruz. Tradeoffs Between Branch Mispredictions and Comparisons for Sorting Algorithms. In Algorithms and Data Structures, volume 3608, pages 385-395. Springer Berlin Heidelberg, Berlin, Heidelberg, 2005. Google Scholar
  4. Gerth Stølting Brodal and Gabriel Moruz. Skewed Binary Search Trees. In Algorithms – ESA 2006, volume 4168, pages 708-719. Springer Berlin Heidelberg, Berlin, Heidelberg, 2006. Google Scholar
  5. Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. Introduction to Algorithms. MIT Press, Cambridge, MA, third edition, 2009. Google Scholar
  6. Amr Elmasry, Jyrki Katajainen, and Max Stenmark. Branch Mispredictions Don’t Affect Mergesort. In Experimental Algorithms, volume 7276, pages 160-171. Springer Berlin Heidelberg, Berlin, Heidelberg, 2012. Google Scholar
  7. John L. Hennessy and David A. Patterson. Computer Architecture, Fifth Edition: A Quantitative Approach. Morgan Kaufmann Publishers Inc., San Francisco, CA, USA, 5th edition, 2011. Google Scholar
  8. Kanela Kaligosi and Peter Sanders. How Branch Mispredictions Affect Quicksort. In Algorithms – ESA 2006, volume 4168, pages 780-791. Springer Berlin Heidelberg, Berlin, Heidelberg, 2006. Google Scholar
  9. David A. Levin, Yuval Peres, and Elizabeth L. Wilmer. Markov Chains and Mixing Times. American Mathematical Society, 2008. URL:
  10. Conrado Martínez, Markus E. Nebel, and Sebastian Wild. Analysis of branch misses in quicksort. In Proceedings of the Twelfth Workshop on Analytic Algorithmics and Combinatorics, ANALCO 2015, San Diego, CA, USA, January 4, 2015, pages 114-128, 2015. URL:
  11. Ira Pohl. A sorting problem and its complexity. Communications of the ACM, 15(6):462-464, 1972. Google Scholar
  12. Salvador Roura. Improved master theorems for divide-and-conquer recurrences. Journal of the ACM, 48(2):170-205, 2001. URL:
  13. Peter Sanders and Sebastian Winkel. Super scalar sample sort. In Algorithms – ESA 2004, volume 3221 of Lecture Notes in Computer Science, pages 784-796. Springer Berlin Heidelberg, 2004. URL:
Questions / Remarks / Feedback

Feedback for Dagstuhl Publishing

Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail