This applies to most Ubuntu based Distros.
Swappiness
The
swappiness setting determines when a system begins swapping data to the hard disk. A low value makes more use of memory and less use of the swap partition.
As memory storage is many times faster than hard disk storage this is what we want.
The default setting is 60, which makes swapping begin early. Lowering to, say 10 sometimes makes a significant improvement in speed, dependent on the hard disk type and workload.
To test it (for the present session only, permanent settings are unchanged) one simply does the following:
- Copy the command
Code:
cat /proc/sys/vm/swappiness
to the terminal and press Enter. You will now see the present value of swappiness.
- Spend some minutes browsing. Notice the speed (or lack thereof).
- After that run the command
Code:
sudo sysctl vm.swappiness=10
- Continue browsing. Do you now have a faster system with less hard disk activity?
If one wants to make the setting permanent the line
vm.swappiness = 10 has to be added to
/etc/sysctl.conf. It's done with the command
Code:
sudo sed -i '$ a\vm.swappiness = 10' /etc/sysctl.conf
The new setting is activated in next boot. In effect it moves workload from a slow, rotating hard drive to the memory modules, which are faster than a solid state drive, and it could be referred to as the poor man's SSD.