Abstract
Modern analytic databases typically rely on partitioning to parallelize GROUP BY operations, avoiding the contention inherent in shared global states. However, this paper demonstrates that a "fully concurrent" approach using a shared global hash table can match or outperform partitioning by optimizing for the specific "get-or-insert" pattern of aggregation. By stripping away general-purpose features and employing techniques like "fuzzy ticketing" and zero-allocation memory management, the authors show that global hash tables are a highly viable alternative for many-core architectures.
Introduction: The Partitioning Paradigm vs. Shared State
In SQL, GROUP BY is a fundamental operation for data analysis. To process massive datasets on modern multi-core CPUs, databases must parallelize this work. The dominant strategy today is partitioning: threads aggregate data into local hash tables and then "shuffle" or re-partition those results into a global state. This design is intended to avoid high contention—where multiple threads fight over the same memory addresses—associated with shared, concurrent hash tables.
However, partitioning introduces its own overhead. Data is often processed twice (once locally and once globally), and the approach can struggle under memory pressure. This paper challenges the status quo by asking: Are concurrent hash tables actually slow, or are we just using the wrong ones? The authors argue that general-purpose concurrent hash tables carry unnecessary baggage, such as support for deletes and complex resizing. By building a purpose-built concurrent hash table for aggregation, they demonstrate that a global shared-state approach is competitive and often superior.
Methodology: Decomposing Concurrent Aggregation
The authors decompose fully concurrent aggregation into two distinct phases: Ticketing and Partial Aggregate Update.
1. Ticketing
In this phase, each unique key is assigned a unique integer "ticket" (an index) via a shared concurrent hash table.
- Folklore*: A customized, lockless linear-probing hash table using single-word Compare-And-Swap (CAS) instructions. It reserves specific values to indicate "empty" or "write-in-progress" states.
- Fuzzy Ticketer: To prevent a bottleneck where every thread contends for a single atomic counter, threads claim a range of tickets at once.
- Zero-Allocation: The system uses OS-level
calloc(copy-on-write) tricks to ensure that massive memory allocations for global tables do not block execution threads.
2. Partial Aggregate Update
Once a thread has a ticket, it updates the corresponding value (e.g., a SUM or COUNT). The authors evaluated three strategies:
- Atomic: Using atomic instructions for global updates.
- Locking: Employing fine-grained locks per ticket.
- Thread Local: Each thread maintains its own vector of values indexed by global tickets, which are merged at the end.
Experimental Setup
The study used synthetic datasets of 100 million 64-bit key-value pairs to stress-test the system across:
- Cardinality: Low (1,000), High (10 million), and Unique (100 million) keys.
- Distributions: Uniform, Zipfian (moderate skew), and "Heavy-hitter" (50% of data belongs to one key).
- Hardware: Evaluation on AMD EPYC (48 cores/96 threads), ARM Ampere Altra (80 cores), and Intel Xeon (24 cores).
Key Insights: Why Global Tables Scale
The research yielded several counter-intuitive findings regarding many-core aggregation:
- Linear Probing Superiority: For insert-only aggregation workloads, complex schemes like Cuckoo or Iceberg hashing perform worse due to bookkeeping overhead. Simple linear probing with a lockless "fast path" is the most efficient.
- The Cost of Allocation: In high-cardinality scenarios, the time spent allocating the hash table can exceed the computation time. "Zero-allocation" strategies are critical for scaling.
- Contention is Overstated: While shared-state approaches are often feared, the "ticketing" phase scales remarkably well even with moderate skew (Zipfian). Only extreme "heavy-hitter" scenarios truly break the concurrent model.
Performance Evaluation
The specialized global hash table (Folklore*) demonstrated significant performance gains over traditional methods.
- Throughput: At low cardinality, the "Thread Local" concurrent approach achieved 1.78x higher throughput than the state-of-the-art partitioning method used in DuckDB.
- Scaling: On a 48-core AMD system, Folklore* achieved a 37.6x speedup for low cardinality and 13.8x for unique keys.
- Memory Efficiency: Atomic-based global aggregation uses significantly less memory than partitioning at high cardinalities by avoiding the overhead of multiple local hash tables.
Conclusion and Future Work
While partitioning remains superior for "heavy-hitter" datasets where a single key dominates, global hash tables prove to be a powerful alternative for most other scenarios. Future work may involve "hybrid" approaches that combine shared global tables with small thread-local tables to handle extreme skew. Additionally, adapting these concurrent models for out-of-core datasets (spilling to disk) remains an open challenge for the database community.
Summary updated