Branch mispredictions don’t affect mergesort

Amr Ahmed Abd Elmoneim Elmasry, Jyrki Katajainen, Max Stenmark

9 Citations (Scopus)

Abstract

In quicksort, due to branch mispredictions, a skewed pivot-selection strategy can lead to a better performance than the exact-median pivot-selection strategy, even if the exact median is given for free. In this paper we investigate the effect of branch mispredictions on the behaviour of mergesort. By decoupling element comparisons from branches, we can avoid most negative effects caused by branch mispredictions. When sorting a sequence of n elements, our fastest version of mergesort performs n log 2 n + O(n) element comparisons and induces at most O(n) branch mispredictions. We also describe an in-situ version of mergesort that provides the same bounds, but uses only O(log 2 n) words of extra memory. In our test computers, when sorting integer data, mergesort was the fastest sorting method, then came quicksort, and in-situ mergesort was the slowest of the three. We did a similar kind of decoupling for quicksort, but the transformation made it slower.

Original languageEnglish
Title of host publicationExperimental Algorithms : 11th International Symposium, SEA 2012, Bordeaux, France, June 7-9, 2012. Proceedings
EditorsRalf Klasing
Number of pages12
PublisherSpringer
Publication date2012
Pages160-171
ISBN (Print)978-3-642-30849-9
ISBN (Electronic)978-3-642-30850-5
DOIs
Publication statusPublished - 2012
Event11th International Symposium on Experimental Algorithms - Bordeaux, France
Duration: 7 Jun 20129 Jun 2012
Conference number: 11

Conference

Conference11th International Symposium on Experimental Algorithms
Number11
Country/TerritoryFrance
CityBordeaux
Period07/06/201209/06/2012
SeriesLecture notes in computer science
Volume7276
ISSN0302-9743

Fingerprint

Dive into the research topics of 'Branch mispredictions don’t affect mergesort'. Together they form a unique fingerprint.

Cite this