Hash Map Resizing with Deferred Memory Cleanup for Lock-Free Reads
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
In database systems, memory management is inefficient due to the need for immediate freeing of memory portions used by parallel threads, leading to performance bottlenecks and synchronization issues with read/write locks.
Innovation Solution
Implementing a lock-free read access mechanism using garbage collection, where memory is attached to a clean-up system that ensures memory is freed at a future point when no parallel threads are operating, using a clean-up entry system coordinated by a transaction manager.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If read/write locks are used to ensure data consistency during parallel operations, then data integrity is maintained, but system performance and throughput are significantly reduced due to synchronization overhead
Solution Approach 1:
The patent segments the hash map into multiple independent buckets, each capable of being operated on independently by different threads. This segmentation allows concurrent access to different portions of the data structure without requiring global locks, thereby maintaining data consistency while improving system performance through parallelism.
Solution Approach 2:
The patent introduces version numbers as an intermediary mechanism to coordinate access to shared data structures. Instead of using locks, threads read and compare version numbers to determine whether data has been modified, enabling lock-free synchronization that maintains consistency while avoiding the performance overhead of traditional locking mechanisms.
2Quantity of substance
If memory is immediately freed after data structure operations to optimize memory utilization, then memory efficiency is improved, but memory safety is compromised when parallel threads are still accessing the data
Solution Approach 1:
The patent performs preliminary actions by creating a new hash map structure before the old one is fully discarded. The new hash map is allocated and prepared in advance, ensuring that parallel threads continue to access valid data structures. Only after the new structure is fully operational does the system begin the process of freeing the old memory, thereby maintaining memory safety while optimizing utilization.
Solution Approach 2:
The patent uses copying by creating a new hash map structure that duplicates the functionality of the old one. This new copy is used by parallel threads while the old structure's memory can be safely freed. The copying approach ensures that memory is reclaimed only after the new structure is fully operational, maintaining safety while improving memory efficiency.
Data Source
AI summary
Disclosed herein are system, method, and computer program product embodiments for providing a lock-free read access to one or more data structures. An embodiment operates by allocating a first portion of a memory corresponding to a first data structure of the one or more data structures, the first data structure comprising a size. The embodiment then performs a first operation associated with the first data structure. The embodiment then receives a first request to insert second data to the first data structure, and determines whether an increase of the size is to be executed. The embodiment then, based on the determination that an increase of the size is to be executed, inserting the second data to a modified first data structure, comprising: executing garbage collection to free-up the first portion of the memory based on at least one parallel operation associated with the first data structure.


