High-Performance and Flexible Parallel Algorithms for Semisort and Related Problems

Xiaojun Dong, Yunshu Wu, Zhongqi Wang, Laxman Dhulipala, Yan Gu, Yihan Sun

TL;DR

This paper introduces new parallel algorithms for the semisort problem, which groups records with identical keys together without fully sorting them. Their approach significantly outperforms existing methods in practice, offering a more flexible and efficient solution for a wide range of applications in areas like graph analytics and data processing.

What Problem Does This Paper Address?

Semisort is a crucial building block for many parallel algorithms, enabling efficient data organization by grouping records with the same key. While theoretically optimal semisort algorithms exist, practical implementations often resort to full sorting or specialized integer sorting due to performance bottlenecks in existing semisort algorithms. These bottlenecks include excessive random memory access, I/O inefficiency, and restrictive interfaces that require pre-hashing keys. This disconnect between theoretical efficiency and practical performance hinders the adoption of semisort in real-world applications. The authors aim to bridge this gap by developing a high-performance, flexible, and practical parallel semisort implementation.

Methods

The authors propose a new parallel semisort algorithm that builds upon the framework of existing work but introduces several key innovations:

  • I/O-Friendly Distribution: Instead of using parallel hash tables for scattering records (which causes random memory access), their algorithm employs a "blocked distributing" technique. This involves partitioning the input into subarrays, counting records per bucket within each subarray, and then using prefix sums to determine exact bucket offsets for efficient, cache-friendly data placement. This method is stable and race-free.
  • Recursive Local Refining: Heavy keys (those appearing frequently) are placed directly into their final positions. Light keys are handled recursively. The recursion stops when the subproblem size is small enough to fit into cache, at which point a sequential semisort (or sort for semisort<) is performed. This recursive approach allows for the detection of "medium-level" heavy keys in subsequent rounds.
  • Flexible Interface: The algorithm directly handles arbitrary key types and user-defined hash functions, eliminating the need for pre-hashing and collision resolution steps that plagued previous methods. This flexibility also extends to supporting histogram and collect-reduce operations with minor modifications.
  • Stability and Determinism: By avoiding parallel hash tables and employing careful data distribution, the algorithms are stable (preserving relative order of equal keys) and internally deterministic.

Datasets

The authors evaluated their algorithms using:

  • Synthetic Datasets: Generated with uniform, exponential, and Zipfian distributions to test performance across various data skewness levels.
  • Real-World Datasets:
    • Graph Transposing: Four directed graphs (soc-LiveJournal, twitter, Cosmo50, sd_arc) were used.
  • N-Gram Processing: 2-gram and 3-gram datasets derived from Wikipedia.

Key Insights and Ideas

  • The Practical Bottleneck is I/O, Not Asymptotics: The paper strongly emphasizes that for parallel algorithms like semisort, efficient memory access patterns and I/O performance are far more critical in practice than theoretical asymptotic bounds.
  • "Blocked Distributing" is Key to Performance: Replacing random hash table lookups with a structured, blocked distribution strategy dramatically improves performance by leveraging cache locality and reducing memory contention.
  • Flexibility is Not Just a Feature, It's a Performance Enabler: By designing a flexible interface that avoids pre-processing, the authors not only make their algorithm more broadly applicable but also eliminate significant performance overheads.
  • Recursive Refinement Adapts to Data Skew: The recursive approach to handling light keys allows the algorithm to adapt to varying degrees of key duplication, efficiently processing both highly skewed and more uniform data.

Key Results

  • Significant Speedups: The proposed semisort algorithms consistently outperform existing state-of-the-art parallel sorting and semisorting methods. On average, they are 1.35x faster than the best baselines and up to 3.4x faster than the previous semisort algorithm (GSSB) for 10⁹ input data.
  • Broad Applicability: The algorithms achieve high performance across various input sizes, key types (32-bit, 64-bit, 128-bit), and data distributions.
  • Real-World Performance Gains: In applications like graph transposing and n-gram processing, their algorithms demonstrated significant performance improvements over existing methods.
  • Scalability: The algorithms exhibit excellent parallel scalability, achieving near-linear speedup with increasing thread counts.
  • I/O Efficiency: The new algorithms achieve optimal O(n/B) I/O cost, a significant improvement over previous methods.

Limitations and Future Work

  • In-place Optimization: While the authors discuss an "in-place optimization" by swapping arrays, the algorithm still uses O(n) extra space. Reducing this space complexity is mentioned as a future direction.
  • Parameter Tuning: The performance is sensitive to parameter choices (subarray size, light bucket number, base case size), and while they provide practical settings, optimal tuning for specific inputs might be an area for further exploration.
  • Future Work: The authors suggest exploring further optimizations for the distribution step, potentially borrowing ideas from other in-place sorting algorithms, to further improve overall performance and reduce space usage. They also plan to integrate their code into the ParlayLib library.

Summary updated

BibTeX
@inproceedings{dong2023high,
  author = {Xiaojun Dong and Yunshu Wu and Zhongqi Wang and Laxman Dhulipala and Yan Gu and Yihan Sun},
  title = {{High-Performance and Flexible Parallel Algorithms for Semisort and Related Problems}},
  booktitle = {SPAA},
  year = {2023},
  doi = {10.1145/3558481.3591071},
}

Loading related content...

Figure