Nested Hierarchical Heap for Parallel Memory Allocation
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
In parallel programming, memory allocation from a shared heap becomes contentious between multiple threads, leading to potential errors and poor performance due to the need for exclusive access, which results in serialization and inefficient memory management.
Innovation Solution
A nested hierarchical heap with a lock-free mechanism allows multiple threads to allocate and release memory in parallel by organizing memory into fixed-size blocks at each level, enabling atomic operations and defragmentation to prevent fragmentation.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If a lock is used to restrict heap access to one thread at a time, then memory allocation safety is ensured, but execution performance deteriorates due to serialisation
Solution Approach 1:
The heap is divided into multiple independent levels (Level 1, Level 2, Level 3, etc.), where each level contains blocks of memory that can be allocated independently. This segmentation allows different threads to access different levels simultaneously without interference, eliminating the need for locks while maintaining allocation safety through the hierarchical structure.
Solution Approach 2:
The patent introduces a hierarchical dimension to memory allocation, organizing memory not as a single flat heap but as multiple stacked levels. This dimensional transformation enables threads to operate in different hierarchical dimensions simultaneously, achieving parallel execution without contention for the same memory region.
2Productivity
If multiple threads access the heap simultaneously without locks, then execution performance improves through parallelism, but memory allocation errors occur due to contention
Solution Approach 1:
The heap is segmented into multiple levels with independent access paths. Each level can be accessed by different threads simultaneously without contention, as long as they operate on different levels. This segmentation enables safe parallel access while maintaining allocation correctness through the hierarchical separation.
Solution Approach 2:
The hierarchical structure acts as an intermediary between threads and the memory heap. Instead of threads directly contending for the same memory region, the hierarchy mediates access by routing requests through different levels, thereby preventing contention while enabling parallel execution.
3Device complexity
If memory is allocated from a single-level heap, then the structure is simple, but memory fragmentation occurs over time as memory is released and reallocated
Solution Approach 1:
The heap is segmented into multiple levels, where each level handles a specific range of memory sizes. When memory is released at a lower level, it can be efficiently reallocated at that same level without affecting higher levels. This segmentation prevents fragmentation from propagating throughout the entire heap, maintaining memory contiguity and simplifying the overall structure.
Solution Approach 2:
The hierarchical structure performs preliminary organization of memory into predefined levels and blocks before allocation occurs. This preliminary structuring ensures that memory is allocated and freed in an organized manner, preventing fragmentation from occurring in the first place and eliminating the need for complex defragmentation operations.
Data Source
AI summary
One embodiment of the present invention sets forth a technique for dynamically allocating memory using a nested hierarchical heap. A lock-free mechanism is used to access to a hierarchical heap data structure for allocating and deallocating memory from the heap. The heap is organized as a series of levels of fixed-size blocks, where all blocks at given level are the same size. At each lower level of the hierarchy, a collection of N blocks in the lower level equals the size of a single block at the level above. When a thread requests an allocation, one or more blocks at only one level are allocated to the thread. When threads are finished using an allocation, each thread deallocates the respective allocated blocks. When all of the blocks for a level have been deallocated, defragmentation is performed at that level.


