Parallel Memory Reclaiming via Dedicated Worker Threads
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
The existing memory reclaiming rate in Linux systems is relatively low, leading to severe memory allocation performance issues and degraded user experience when system memory is insufficient, due to the single-threaded nature of memory reclaiming processes.
Innovation Solution
Implementing a dedicated worker thread per CPU to process memory reclaiming tasks in parallel, utilizing a work queue mechanism to allocate tasks to idle worker threads, and employing scan control structures and page frame descriptors to determine and manage memory pages for swapping out and swapping in, thereby accelerating memory reclaiming and improving user experience.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If memory reclaiming is performed in a single thread, then the system structure is simple, but the memory reclaiming rate is low and memory allocation performance is severely affected
Solution Approach 1:
The patent divides the memory reclaiming process into multiple independent worker threads, each responsible for reclaiming memory pages. This segmentation allows parallel execution of memory reclaiming operations across multiple CPU cores, significantly improving the memory reclaiming rate while maintaining manageable system complexity through modular thread design
Solution Approach 2:
The patent transitions from single-threaded sequential memory reclaiming to multi-threaded parallel memory reclaiming by utilizing the CPU core dimension. This dimensional change enables simultaneous memory reclaiming operations across multiple processing units, directly addressing the bottleneck in memory reclaiming rate without proportionally increasing system complexity
2Productivity
If memory reclaiming is performed in a single thread, then the implementation is simple, but memory allocation performance is severely affected when system memory is insufficient
Solution Approach 1:
The patent segments the memory allocation process into multiple concurrent worker threads that can independently perform memory reclaiming operations. This segmentation enables parallel memory allocation and reclaiming, significantly improving memory allocation performance during memory pressure conditions while managing implementation complexity through structured thread coordination
Solution Approach 2:
The patent ensures continuous memory reclaiming operation through multiple worker threads that can execute reclaiming tasks simultaneously without interruption. This continuous parallel action maintains memory allocation performance by constantly freeing memory pages, preventing the system from stalling during memory pressure events
3Speed
If synchronous reclaiming is performed, then memory allocation is fast, but system responsiveness is reduced due to blocking
Solution Approach 1:
The patent introduces dynamic memory reclaiming where worker threads can be woken up or scheduled based on memory pressure conditions rather than executing synchronously. This dynamic approach allows the system to maintain fast memory allocation speed when needed while reducing blocking during normal operation, improving overall system responsiveness through conditional synchronous/asynchronous reclaiming
Solution Approach 2:
The patent implements preliminary memory reclaiming by having worker threads proactively reclaim memory pages before they are needed, rather than waiting for memory pressure to trigger synchronous reclaiming. This preliminary action reduces the blocking time during actual memory allocation operations, improving both allocation speed and system responsiveness
Data Source
Figure 1
Figure 2
Figure 3A
AI summary
A memory management method and apparatus are disclosed, to resolve an existing problem that a memory reclaiming rate is relatively low, severely affecting memory allocation performance in a scenario in which system memory is insufficient. The method includes: determining a memory page that needs to be swapped out of a memory (S21); for each memory page that needs to be swapped out, generating, based on the memory page, a work task used to reclaim the memory page (S22); and determining a dedicated worker thread in an idle state, and allocating each work task to the dedicated worker thread in an idle state for execution (S23). In this way, a plurality of CPUs process memory reclaiming in parallel, thereby accelerating memory reclaiming, and improving user experience.