Introduction
Hash tables are fundamental to efficient data retrieval, typically offering $O(1)$ lookup complexity. However, they possess a significant vulnerability: hash collisions. Whether triggered by massive data bursts, logic errors, or deliberate Denial-of-Service (DoS) attacks, high collision rates can degrade performance to $O(n)$, effectively turning a high-speed table into a slow linked list.
Existing mitigations generally fall into two categories. Resizable hash tables can adjust their size but often remain tied to a single hash function. Dynamic hash tables allow for swapping hash functions entirely but frequently rely on per-bucket locks. Under heavy load, these locks become major bottlenecks, leading to severe thread contention and performance drops. DHash addresses these issues by providing a dynamic hash table that maintains the performance of a lock-free concurrent data structure.
The DHash Architecture
The primary innovation of DHash lies in its "rebuild" process, which allows moving nodes from an old table to a new one (with a different hash function) without blocking concurrent operations.
The Hazard Period and Global Pointer
During the transition, a node enters a "hazard period" — a brief window where it has been removed from the old table but not yet placed in the new one. To ensure no node "disappears" during a lookup, DHash introduces a global pointer, rebuild_cur, which tracks the node currently in transit.
Ordered Search Sequence
To maintain correctness, DHash enforces a strict search order:
- Check the old table.
- Check the global pointer (
rebuild_cur). - Check the new table.
This sequence guarantees that a node is always visible to lookup operations, regardless of its migration status. DHash leverages Read-Copy Update (RCU) for synchronization, allowing readers to traverse the table without acquiring locks, which is vital for high-throughput, read-heavy workloads.
Implementation and Modularity
DHash is designed as a modular framework. The individual buckets can be implemented using various lock-free or wait-free algorithms, such as Michael’s linked list or skip lists, allowing developers to balance engineering complexity with progress guarantees.
Performance Evaluation
The authors evaluated DHash using the hashtorture benchmark across three architectures: Intel Ivy Bridge (24 cores), IBM Power9 (16 cores), and Cavium ARMv8 (96 cores). DHash was compared against standard Linux kernel implementations, including rhashtable (HT-RHT) and the networking subsystem's dynamic table (HT-Xu).
Key Findings
- High Throughput: At a load factor of 20, DHash outperformed competitors by 1.4x to 2.0x.
- Resilience to Collisions: Under extreme load (load factor of 200), simulating a collision attack, DHash achieved a speedup of 2.3x to 6.2x over alternatives.
- Scalability: On the 96-core ARMv8 platform, DHash demonstrated near-linear scaling, avoiding the performance plateaus seen in lock-based designs.
- Predictable Rebuilding: Rebuild time scales linearly with the number of nodes, making it suitable for real-time applications.
Conclusion
DHash successfully decouples hash table policy from mechanism, enabling on-the-fly hash function swaps without sacrificing concurrency. By making intermediate states visible via the rebuild_cur pointer and utilizing RCU, it provides a robust defense against collision-based performance degradation. While current rebuild requests are serialized via a mutex and memory reclamation is asynchronous, DHash represents a significant step forward in high-performance, resilient data structure design.
Summary updated