Abstract
Sorting is a fundamental building block in computing, yet a significant gap has persisted between theoretical parallel integer sorts and the algorithms used in practice. This paper addresses this gap by providing tighter complexity bounds for practical algorithms and introducing DovetailSort (DTSort). DTSort is a novel, stable parallel algorithm that combines the bit-level efficiency of radix sorts with the duplicate-handling capabilities of comparison sorts. Empirical evaluations demonstrate that DTSort achieves up to a 2.3× speedup over state-of-the-art baselines on datasets with heavy duplicates and maintains near-linear scalability on high-core-count systems.
Introduction
When keys are integers, integer sorting algorithms like Radix Sort can theoretically outperform comparison-based sorts such as Quicksort or Samplesort. However, two major issues have historically hindered the adoption of theoretically optimal integer sorts. First, the most efficient theoretical algorithms are often too complex for practical implementation, leading to a "theory-practice gap" where implemented versions lack rigorous analysis. Second, standard Most-Significant-Digit (MSD) integer sorts struggle with duplicate keys. Unlike comparison sorts, which can "skip" duplicates once identified, MSD sorts must partition keys into buckets based on bit-prefixes, often failing to detect duplicates until the final levels of recursion.
The DovetailSort Algorithm
To address these challenges, the authors introduce DovetailSort (DTSort). DTSort operates within the MSD framework but incorporates a sampling phase inspired by comparison-based sorting to identify and handle frequent keys early.
Sampling and Heavy Key Detection
At each recursive level, DTSort samples keys to identify "heavy keys"—those appearing with high frequency. By identifying these keys early, the algorithm can bypass redundant bit-level partitioning for a significant portion of the dataset.
Dovetail Merging
The core innovation of the algorithm is the Dovetail Merge technique. Once heavy keys are identified, they are separated from "light" keys. Heavy keys are placed into dedicated buckets, allowing them to skip further recursion. To maintain stability (preserving the relative order of equal keys) while minimizing memory movement, the dovetail merge interleaves heavy and light buckets. This process can be performed in-place or with minimal temporary storage, avoiding the expensive global data copies typically required by standard merging techniques.
Theoretical Foundation
Beyond the algorithm itself, this research provides a solid mathematical foundation for practical MSD sorts. The authors prove that a class of practical MSD sorts, including DTSort, possesses a work complexity of $O(n \sqrt{\log r})$ for $n$ keys in the range $[0, r-1]$. This bound is significant as it aligns asymptotic theory with the empirical performance engineers have observed in real-world high-performance computing environments.
Experimental Evaluation
DTSort was evaluated against six state-of-the-art baselines, including PLIS, IPS2Ra, and Samplesort, across a variety of distributions:
- Synthetic Distributions: Uniform, Exponential, and Zipfian distributions were used to test varying levels of duplicates.
- Adversarial Distribution: The authors introduced Bit-Exponential (BExp), designed to create uneven subproblems and force frequent dovetail merging.
- Real-World Applications: The algorithm was tested on Graph Transpose tasks (sorting edges of massive graphs like Clueweb with 42.6B edges) and Morton Sort (sorting multidimensional points for geometric processing using OpenStreetMap data).
Key Results
- Performance: On 32-bit keys, DTSort is 1.27–1.47× faster than the best baselines on average. On datasets with heavy duplicates, the advantage increases to a 2.3× speedup over PLIS.
- 64-bit Efficiency: The performance gap widens on 64-bit keys, where DTSort consistently outperforms both integer and comparison-based baselines.
- Scalability: The algorithm demonstrates near-linear scalability, achieving a 72× speedup on a 96-core machine.
- Application Impact: In graph transposition tasks, DTSort provided up to a 1.3× speedup over the best existing baselines, highlighting its utility in large-scale data pipelines.
Discussion and Limitations
While DTSort represents a significant advancement, certain bottlenecks remain. In highly adversarial cases like the BExp distribution, the dovetail merging step can account for up to 50% of the runtime when subproblems contain a complex mix of heavy and light keys. Additionally, the "distributing" (counting sort) phase remains a major component of the total execution time. Future work may explore hardware-specific optimizations, such as SIMD instructions, to accelerate this phase. Finally, like many high-performance parallel sorts, DTSort requires $O(n)$ extra memory, which may be a consideration for memory-constrained environments.
Conclusion
DTSort successfully bridges the gap between the bit-level efficiency of radix sorts and the duplicate-handling strengths of comparison sorts. By providing both a high-performance implementation and a rigorous theoretical analysis, this work offers a new standard for parallel integer sorting in both theory and practice.
Summary updated