Facebook Developing THP Shrinker To Avoid Linux Memory Waste

Written by Michael Larabel in Linux Kernel on 26 August 2022 at 05:17 AM EDT. 14 Comments
Meta/Facebook engineers have announced their work on THP Shrinker as a way for Linux's Transparent Hugepages (THP) to be more efficient and avoiding memory waste by removing under-utilized transparent hugepages.

THPs are great for efficiency with fewer TLB cache misses for some workloads, but the 2MB vs. 4kb page size can lead to a lot of wasted memory if not being effectively utilized. Facebook engineers found about 2.7GB of memory waste on one of their platforms from under-utilized THPs.

With the THP Shrinker they are working on for the Linux kernel, they aim to address that waste while still enjoying THPs for greater CPU efficiency. The THP Shrinker will split the least utilized hugepages.

THP Shrinker aims to avoid wasting RAM and could open up Transparent Hugepages to being unconditionally enabled and thereby deprecating the madvise-based opt-in.

Facebook engineers are working to add additional tuning around this THP Shrinker and potentially tied into CPU/IO/Memory pressure events. Eventually the engineers are hoping that with the THP Shrinker, they could just deprecate Linux's madvise THP mode and switch to THP being enabled for all applications.

More details on this interesting kernel development via lore.kernel.org. Right now this THP Shrinker is just a little more than 500 lines of new kernel code.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week