Versioned Insert-Only Hash Table for Concurrent In-Memory Access
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing hash table implementations in columnar in-memory data stores face challenges in supporting concurrent reader and writer access efficiently, leading to potential data corruption and performance issues when handling large datasets.
Innovation Solution
A versioned insert-only hash table design that uses a backing array with pointers to buckets, incorporating a modulo operation for hash function-based positioning, compare-and-swap techniques for atomic writes, and a semaphore mechanism to manage concurrent access, ensuring that writers can insert key-value pairs without overflows and maintain data integrity while allowing readers to access the hash table without deallocation.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If a traditional hash table is used for concurrent access, then readers can access data, but writers may cause data corruption or performance degradation
Solution Approach 1:
The hash table is segmented into multiple independent backing arrays, each serving as a separate version. Writers operate on one backing array while readers can access other backing arrays simultaneously, eliminating conflicts between concurrent reads and writes.
Solution Approach 2:
A new backing array is allocated and prepared in advance before writers need to insert data. This preliminary allocation allows writers to start operations on the new array without waiting for the old array to be fully cleared, improving concurrency performance.
2Quantity of substance
If the backing array size is increased to handle more key-value pairs, then write capacity improves, but memory consumption increases
Solution Approach 1:
Old backing arrays are discarded after their data is migrated to new backing arrays. This allows memory to be recovered and reused, enabling the system to handle large quantities of key-value pairs over time without continuously increasing memory consumption.
Solution Approach 2:
The system periodically creates new backing arrays and migrates data in batches rather than continuously growing a single large array. This periodic migration approach balances memory usage while maintaining capacity to handle increasing data volumes.
3Reliability
If a semaphore mechanism is implemented for writer synchronization, then data integrity is maintained, but write operation overhead increases
Solution Approach 1:
Instead of using complex synchronization mechanisms like semaphores, the system creates copies of the backing array (new versions) for each write operation. Writers independently modify their copy without blocking others, eliminating synchronization overhead while maintaining consistency through version management.
Data Source
AI summary
At least one read operation is concurrently performed with at least one write operation that each insert a key/value pair into a backing array of a backing hash table of a hash table forming part of a columnar in-memory database. The backing array maps a plurality of pointers each to a respective bucket. Each bucket includes at least one state bit and a hashed value of a corresponding key. Thereafter, for each write operation, a first available position in the backing array at which a pointer to a new bucket containing the key/value pair can be inserted is iteratively determined (such that each first available position has no corresponding pre-existing pointer). Subsequently, for each write operation, the pointer to the new bucket containing the key/value pair is inserted at the corresponding first determined position in the backing array. Related apparatus, systems, techniques and articles are also described.


