Kairui Song of Tencent sent out a new patch series overnight working on enhancing the Linux kernel’s swap code. With the patches there are some memory savings — and more on the way — while also providing for slightly faster performance.
The patch series removes the static “swap_map” and uses the swap table for the swap count directly. This conserves around 30% memory use for the static swap metadata, which amounts to 256MB of memory when mounting a 1TB swap device… Granted, using a 1TB swap device isn’t too common outside of perhaps some very large server setups.
Another 512MB or so of memory savings is expected from some ongoing work for another round of swap / memory management patches.
Besides those swap metadata memory savings, the performance is found to be slightly faster when under global memory pressure. Kernel builds under memory pressure on some smaller x86_64 and ARM64 VMs with limited RAM were found to be 1.6% to 2.4% faster. Redis/Valkey was also around 1.5% faster with this patch series.
Those interested in this work can find these latest swap/mm patches out for review on the Linux kernel mailing list.
