Linux 7.2 includes a series of patches on its MultiGen-LRU algorithm, allowing a MongoDB performance gain for free under some workloads. This post provides a brief explanation of how Linux memory pages work, as well as the MongoDB-related MGLRU changes.
Linux Memory Pages Primer
Warning: This is a simplified explanation, if you want to go deeper start from here.
Reading files from disks is an expensive and slow activity. For this reason, when Linux accesses a file for the first time, it puts the file’s data in in-memory pages. A page is an abstraction that acts like a cache: if you need the same file content again, it will be served from the memory, skipping the slow disk access.
On the other hand, when you write to a file, the corresponding page is updated first and, later, the changes are synced with the file on the disk. A page that contains changes not already written out to disk is called dirty.
Since physical memory is limited, pages can be reused. Only non-dirty pages can be reused safely, so, eventually, all dirty pages will be synchronised with the disk. This process is also called dirty pages writeback.
When a page is not dirty and not active anymore, it can be resued or reclaimed by the Kernel.
Active, Inactive, Anonymous and Reclaimed Pages
The Kernel maintains a list of pages named active working in a least-recently-used (LRU) fashion; the head of the list contains pages used recently. When a page became unused (aka the tail of active list is reached), it is moved to the inactive list. The feature used to keep the lists is the page access recency.
When a page is not backed by a file (e.g. programs stacks, heaps and mmap calls), it is called anonymous, and another couple of active/inactive lists are used.
Since such page contains vital data for running programs, the Kernel tends to be more conservative towards them, at the expense of the file-backed pages.
Understanding what pages will be accessed again, and so what pages can be reclaimed, is a difficult and CPU-expensive task, especially when you have multiple lists to check.
Multi-Gen LRU
In 2021, Yu Zhao posted a series of patches, named Multi-Gen LRU, adding a new algorithm for pages management. The idea is simple but powerful - instead of having only two active/inactive LRU lists, a set of lists based on pages’ age is used. Each list represents a generation (a time frame), and pages are moved from the youngest to the oldest generation passing through all the intermediate generations. Only pages in the oldest generation can be reclaimed
From time to time, the last access time of pages is checked, and pages are moved accordingly. Accessed pages are moved to the youngest generation and the others are moved to an older generation (relatively to their current generation).
This approach is cheaper, from a CPU perspective, and produces better results in terms of reclaimed pages. Over the years, MGLRU has been improved and more features have been added, but its core idea is still the same.
The Linux Kernel documentation contains an overview page of Multi-Gen LRU and an admin one. For more accessible content, start from the initial LWN article about MGLRU and then move to their Memory Management archives.
MongoDB and MGLRU Linux 7.2 changes
In April 2026, a patch series from Kairui Song improved the way MGLRU reclaim works and the dirty pages handling.
The change is quite small (149 insertions and 192 deletions in a single file - mm/vmscan.c), but the results are interesting.
He claims a 30% performance increase in MongoDB YCSB benchmark with NVME storage and 100% with old HDD and network storage:
Running YCSB workload (recordcount:20000000 operationcount:6000000, threads:32), which does 95% read and 5% update to generate mixed read and dirty writeback. MongoDB is set up in a 10G cgroup using Docker, and the WiredTiger cache size is set to 4.5G, using NVME as storage. We can see a significant performance improvement after this series. The test is done on NVME and the performance gap would be even larger for slow devices, such as HDD or network storage. We observed over 100% gain for some workloads with slow IO.
The patch series has already been merged for 7.2 and is expected to be released by the end of August 2026.
How to check if MGLRU is enabled
MGLRU is activated by a Linux Kernel option named CONFIG_LRU_GEN_ENABLED.
You can check if it is available and active on your system by looking into the Kernel config file.
$ cat /boot/config-7.0.12-201.fc44.x86_64 | grep -i lru
CONFIG_LRU_GEN=y
CONFIG_LRU_GEN_ENABLED=y
After installing Linux 7.2+ on your system, if the option is enabled, MongoDB will benefit from these Linux internal improvements. Otherwise, you need to compile your Kernel from scratch.