Tip for Desktop Memory management, new vm tuning option
Rashkae
ubuntu at tigershaunt.com
Tue Jul 30 12:40:17 UTC 2019
Recent Linux Kernels since Ubuntu 16.04 have had changes to Virtual
Memory management that drastically hurt performance on Desktop loads
where RAM is not always sufficient for all running apps. With 4 to 8 GB
desktops it's easy, if multi-tasking, to starve the RAM. With older V3
and 4.4 Linux kernels, swap on an SSD, you could easily drive the system
memory usage several GB past your RAM and not even notice.
However, with Newer linux kernels, if memory usage approaches your RAM,
applications that try to allocate a large chunk of memory could quickly
send a system into a swap tailspin that renders the system inoperable
until rebooted or processes manually killed. I've tripped over this
several times over the past few years, and I finally found the change
that causes it, Documented Here:
https://www.fclose.com/linux-kernels/642756/mm-scale-kswapd-watermarks-in-proportion-to-memory-linux-4-6/
The key to avoiding this swap lock problem is to increase
/proc/sys/vm/watermark_scale_factor
It defaults to 10. In my testing, 100 is still not enough to avoid the
problems, but increasing it to 500 *drastically* improves the computer's
ability to handle memory over-commit without falling on it's face.
On my 8GB system, I can have several browser windows, thunderbird, Open
Office, calibre and a few movies playing, (brining my RAM usage past
6GB), then open a 4GB Windows 10 VirtualBox instance, and everything
works with no noticeable slowdowns or hitches. This was completely
impossible before.
If you want to try this, the change can be made permanent by adding this
line in /etc/sysctl.conf. Run sudo sysctl --system to apply changes
without reboot.
vm.watermark_scale_factor=500
More information about the ubuntu-users
mailing list