Gaining better performance via swappiness

From The World according to Vissie
Jump to navigation Jump to search

This is originally from Ubuntu Wiki

There is a parameter which defines the attitude of kernel to swap. This parameter is controlling how soon the kernel begin to fill the swap.

This parameter is called "swappiness" and has a value in the 0-100 range. swappiness=0 means it will use swap as last as possible. swappiness=100 means it will begin to swap very early.

Currently the default value is 60, but lowering to 10 or 5 would cause the machine to be better responsive.

How to check the swappiness value

     $ cat /proc/sys/vm/swappiness


How to change the swappiness value

  • edit the /etc/sysctl.conf:
     $ sudo gedit /etc/sysctl.conf
  • and add this line in the end of the file (change 10 to the value you want):
     vm.swappiness=10
  • save and reboot