FRIDAY, APRIL 17, 2026
malloc — Proposed
Automatic THP in malloc breaks madvise for container hosts
Glibc's automatic THP opt-in via madvise hurts container hosts by allocating huge pages to small management processes instead of actual workloads.
Yutong Sun raises concerns about glibc’s automatic Transparent Huge Pages (THP) opt-in behavior via madvise(MADV_HUGEPAGE) for heap allocations. This breaks the intended semantics of madvise mode where applications explicitly opt-in. On container hosts, this leads to small management processes (container shims) receiving huge page allocations, while actual container workloads do not, wasting memory. The author proposes either reverting the change or making THP usage opt-in.
Technical Tradeoffs
- Automatic THP allocation can be beneficial for some workloads but detrimental in container environments.
- Using GLIBC_TUNABLES is not a stable ABI.
- Disabling THP system-wide penalizes workloads that benefit from it.