Linux Kernel Swappiness



I use an 8GB Ubuntu Desktop. When the memory usage approached 6 GB, the machine was dragged into a swap nightmare. The machine is mostly good, responsive, but the sata hard disk is sub par with the rest of the system. It's slow for read and write. It's slow for booting and extremely slow for swapping.

Researching for Linux hard disk tuning, found a suggestion to change the kernel variable vw.swappiness.

The default value is 60. I reduced it to 10. My machine barely swaps now. Performance is much better - and freezes and reboots don't happen anymore.

# Set the swappiness value as root
echo 10 > /proc/sys/vm/swappiness

# Alternatively, run this 
sysctl -w vm.swappiness=10

# Verify the change
cat /proc/sys/vm/swappiness
10

# Alternatively, verify the change
sysctl vm.swappiness
vm.swappiness = 10

The explanation is that Linux kernel maintains a cache of virtual memory pages in memory. It has to decide how to best use this cache and, for this, replaces vm pages between memory and disk. The higher the number of vm.swappines, the more aggressively the kernel will swap pages. The lower the number, it's less likely that vm pages transfer occur.

Comments

Popular posts from this blog

Ubuntu 17.10 - CIFS Mount Error Code -5

Integrating Drupal 8 Webforms Submissions and Rocket Chat

Instalação eToken Pro no Ubuntu 18.04 para acesso ao eCAC da RFB