Oct 22, 2016

Speed up Ubuntu by configuring swappiness

I forget to config swappiness when my Ubuntu 16.04 installed. So I note it today.
Wiki defines:
Swappiness is a Linux kernel parameter that controls the relative weight given to swapping out runtime memory, as opposed to dropping pages from the system page cache. Swappiness can be set to values between 0 and 100 inclusive.
#Use terminal to see system stats

Swap memory is low because it is hard disk treated as memory. It is second "RAM memory". Ubuntu system comes with a default of 60, meaning that the swap file will be used fairly often if the memory usage is around half of my RAM. You can check your own system's swappiness value by running:

cat /proc/sys/vm/swappiness

I wanna the swap file only be used when my RAM usage is around 80 or 90 percent. To change the system swappiness value, open /etc/sysctl.conf as root. Then, change or add this line to the file:
vm.swappiness = 10
Alternative ways:
# Set the swappiness value as root
echo 10 > /proc/sys/vm/swappiness
# Alternatively, run this 
sysctl -w vm.swappiness=10

No comments:

Post a Comment