MGLRU rewrite targets the working-set numbers clouds actually use
Kairui Song's frequency-guided promotion claims large reclaim gains and a stable active-memory reading, but Andrew Morton is waiting on more review.
A fifth revision of frequency-guided promotion for the kernel's multi-generational LRU is aimed at the reason many operators still refuse to turn the feature on: the working-set numbers it exports are unstable, and cloud platforms use those numbers to decide what to evict.
Kairui Song of Tencent posted the series, following an idea raised at this year's LSF/MM/BPF summit. Depending on the workload, he reports roughly 10% to more than 50% better performance or less I/O, plus a cleanup that drops one page flag. The larger claim is about accounting. Today's MGLRU derives active and inactive sizes from which generation a folio sits in. Aging can flip a large slice of memory from active to inactive at once, with no change in use, and on machines without swap the anon reading can reverse. Kubernetes and similar systems derive a pod's working set from that reading. Song wrote that the unstable figure has been "a major blocker for us to deploy MGLRU widely," and that users have disabled MGLRU to work around it. The new scheme marks a folio active once its access count crosses a threshold, so the exported size no longer jumps when generations age.
Promotion itself is a hybrid. Accesses still raise a per-folio count, and a folio that hits a threshold moves into a newer generation, but reclaim still walks generations rather than sorting by frequency. Aging lowers logical hotness without touching every folio. Song also retunes how MADV_COLD and MADV_PAGEOUT interact with that count, so those hints no longer corrupt it.
Outside tests line up with the claim, with caveats. Tianyi Chen reran an OpenSearch k-NN case whose index files are mapped MADV_RANDOM. Median tail latency fell from about 66 milliseconds under stock MGLRU to about 2 milliseconds, matching the classical LRU, and the index stayed resident instead of being dropped after a scan. Song said the series still does not track MADV_RANDOM accesses, and that refault-distance protection is left for later. Lian Wang of ByteDance said an earlier LevelDB regression on ByteDance machines looks as if it may be covered, but has not rerun v5 yet. Song's own LevelDB numbers show the new code slightly ahead of both classical LRU and current MGLRU, without the side effects of an earlier heuristic.
Andrew Morton called the series "really good" and offered a Tested-by after an automated pass confirmed the gains and failed to break it, while also finding writes through clear_refs about 7% slower. He is not queuing it yet: review is thin, and he asked what others think. Barry Song, whose swappiness rework the series is based on, said he would rather the two land together and hopes to finish a review next week.