Introduction to a WaitFree Hash Table Steven Feldman
Introduction to a Wait-Free Hash Table Steven Feldman (UCF), Pierre La. Borde (UCF), Damian Dechev (Sandia, UCF) Hash Table • • Key-Value pair stores and retrieves data Three Core Functions: – Put, Get, Delete – Constant time: O(1) Design Goals: • • Lock-Free and Wait-Free Nature • All threads make progress Concurrent/Efficient Resize Thread-Death Safety No CAS loops 999999 -1 XYZ 3/11/2005 Lock-Free/Non-Blocking: ensure that no single thread can prevent another from accessing information. Wait-Free: Guarantees that any process can complete any operation in a finite number of steps, regardless of the execution speeds of the other processes. Features: • Probing and non-probing versions • • • No global resize • Concurrent expansion Predictable memory usage • Lookahead Each key has a unique final position MIT Lincoln Laboratory
Brief Algorithm Description Two types of Nodes: – Spine Node: State, Memory Array – Data Node: State, Key, Value Key treated a bit string Divided into blocks Each block determines the position the key belongs in at each level. Composed of Spine Nodes • A position points to a spine or data node • Max depth is X, where 2^X=Spine Length State: Old 0 K: 0 -4 -2 0 K: 2 -0 -2 Traversal Procedure: 1 K: 1 -8 -2 1 K: 2 -1 -2 1) Bits in key are rearranged 2) First X bits determine the location 3) Examine the node A. If Spine Node: Using the next X bits, examine that spine's memory array B. If Data Node: Complete thread's operation 2 2 NULL 3 K: 3 -1 -1 3 NULL 4 Spine 4 K: 2 -4 -4 5 K: 5 -5 -5 5 NULL 6 NULL 7 K: 7 -7 -7 7 K: 2 -0 -7 999999 -2 XYZ 3/11/2005 MIT Lincoln Laboratory
Operations Per Second Performance Comparison 10% Modification 50% Modification 90% Modification 250000 140000 70000 200000 120000 60000 100000 50000 150000 80000 100000 40000 60000 30000 50000 40000 20000 10000 0 1 2 4 8 16 32 64 Number of Threads Performance Analysis: • Wait-Free performs better at Modification > 75% • Algorithm still not optimized • Probing version not worth it. 999999 -3 XYZ 3/11/2005 Legend: Wait-Free Hash Table (Non-Probing) Wait-Free Hash Table (Probing) TBB Concurrent Hashmap CDS Split List Hash Map (Lock-Free) Michaels Lock-Free Hash Map MIT Lincoln Laboratory
Conclusion Future Work: • Additional Functions - Put-if-absent - Put-if-equals - Delete-if-equals • • • Memory pool Optimization of code Integration in real-world applications Acknowledgements: Funding provided by UCF, NSF, and UCF’s YES program Source Code: github. com/Mr. Steven. Feldman/ 999999 -4 XYZ 3/11/2005 MIT Lincoln Laboratory
Example State: Old • Finding Key: 0 -4 -2 • 2 -1 -2 Hashes to 2 -1 -2 • Examines position 1 • Returns associated value • Inserting Key: 1 -2 -3 • 1 -2 -3 Hashes to 5 -6 -1 • Position 5 is occupied • Adds and expands the table 999999 -5 XYZ 3/11/2005 0 K: 2 -0 -2 1 K: 2 -1 -2 State: Old 2 NULL 0 K: 0 -4 -2 3 NULL 1 K: 1 -8 -2 4 K: 2 -4 -4 2 5 NULL 3 K: 3 -1 -1 State: Old 6 NULL 4 Spine 0 NULL 7 K: 2 -0 -7 5 K: 5 -5 -5 1 NULL 6 NULL 2 NULL 7 K: 7 -7 -7 3 NULL 4 NULL 5 5 -5 -5 6 5 -6 -1 7 NULL MIT Lincoln Laboratory
- Slides: 5