Mediatek engineers have proposed Kcompressd as a new addition to the Linux kernel to improve the efficiency of memory reclamation. Mediatek engineers testing these patches on their handheld Linux devices have found huge benefit in alleviating memory pressure and enhancing system responsiveness.
Posted to the Linux kernel mailing list yesterday was the memory management “MM” patch for the Linux kernel proposing Kcompressd as a little more than 100 lines of C code and the potential to have dramatic impact on memory reclaiming performance.
The patch from Mediatek engineer Qun-Wei Lin is summed up as:
“This patch series introduces a new mechanism called kcompressd to improve the efficiency of memory reclaiming in the operating system.
Problem:
In the current system, the kswapd thread is responsible for both scanning the LRU pages and handling memory compression tasks (such as those involving ZSWAP/ZRAM, if enabled). This combined responsibility can lead to significant performance bottlenecks, especially under high memory pressure. The kswapd thread becomes a single point of contention, causing delays in memory reclaiming and overall system performance degradation.Solution:
Introduced kcompressd to handle asynchronous compression during memory reclaim, improving efficiency by offloading compression tasks from kswapd. This allows kswapd to focus on its primary task of page reclaim without being burdened by the additional overhead of compression.In our handheld devices, we found that applying this mechanism under high memory pressure scenarios can increase the rate of pgsteal_anon per second by over 260% compared to the situation with only kswapd. Additionally, we observed a reduction of over 50% in page allocation stall occurrences, further demonstrating the effectiveness of kcompressd in alleviating memory pressure and improving system responsiveness.”
Interesting work and hopefully Kcompressd or some evolution of it will ultimately make it into the mainline Linux kernel for helping with the handheld Linux gaming experience and for other Linux systems routinely under memory pressure.