What it is?

Multi-Gen LRU (MGLRU) is a Linux kernel feature that helps improve page reclaim efficiency by dividing the LRU (Least Recently Used) list into multiple generations. This allows the kernel to more effectively identify and reclaim pages that are less likely to be accessed in the near future.

"MGLRU shows an overall 40% decrease in kswapd https://www.kernel.org/doc/gorman/html/understand/understand013.html CPU usage, in addition to improvements in other UX metrics, e.g., an 85% decrease in the number of low-memory kills and an 18% decrease in rendering latency." https://dev.to/archerallstars/enable-the-magical-multi-gen-lru-aka-mglru-on-opensuse-tumblewed-stay-away-from-oom-today-ji6

More details:

https://docs.kernel.org/admin-guide/mm/multigen_lru.html

https://github.com/hakavlad/mg-lru-helper/blob/main/README.md

Enabling MGLRU (Multi-Gen LRU):

Check whether it is supported by the kernel: grep -Ria CONFIG_LRU_GEN /boot && echo "Y means that it is supported. Otherwise do not continue."

Install the service: sudo wget -q https://pastebin.com/raw/ADq1GETU -O /etc/systemd/system/mglru.service && sudo systemctl daemon-reload && sudo systemctl enable mglru

Check status: cat /sys/kernel/mm/lru_gen/enabled; echo "This should have returned 0x0007. If it returned 0x0000, this means it's not enabled yet - you may need to reboot."

Check thrashing prevention status: cat /sys/kernel/mm/lru_gen/min_ttl_ms; echo "This should have returned 1000 for the optimal thrashing prevention. Otherwise you may need to reboot."

sudo journalctl -kg lru # some details, I can not find anything...


Anyone knows some good resource on tuning and measuring this new LRU?