Wait what? Is swappiness even an actual word? According to Google Chrome’s built in spell checker and most probably any dictionary it is not, but to any Linux user and expert out there, it most definitely is.

So what is swappiness? According to Wikipedia swappiness is “is a property for the Linux kernel that changes the balance between 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. A low value means the kernel will try to avoid swapping as much as possible where a higher value instead will make the kernel aggressively try to use swap space. The default value is 60, and for most desktop systems, setting it to 100 may affect the overall performance, whereas setting it lower (even 0) may improve interactivity (decreasing response latency.)

Here is a brief overview: when applications, data etc is read, it is read into memory. It has to be in memory before it can be used, processed, etc. Memory and disk reads and writes data in units called pages. When pages in memory are unused for a long time, or if they have changed, or if memory becomes full, these pages in the memory have to be written to disk. This process of writing the pages to disk is called swapping. (Swap pages from memory to disk).

A few months ago I installed Ubuntu again, but I’ve had some performance issues. A quick Google revealed good information around the Unity interface and how to make the interface more responsive through some tweaks in Compiz Configuration Manager. These tweaks worked, but my Ubuntu was still extremely unresponsive. I realized that, when launching applications (normal applications, nothing fancy), my disk activity LED would flicker for a long time. Maybe flicker isn’t the word. It would shine like a burning star for a few seconds. Enter swappiness:

By using these commands, I changed my swappiness value to 10, and saw a major increase in responsiveness, especially after the application have been launched for the first time, subsequent launches were a lot quicker:

  • cat /proc/sys/vm/swappiness — check the value of your system’s swappiness
  • sudo gedit /etc/sysctl.conf 
    • Paste the following line (or update it if it already exists) vm.swappiness = 10 (replace 10 with the value you want)

Reboot your system. If you don’t see an increase, or if your system becomes sluggish after a while, play around with the swappiness value and see which one suits you best. For more information check out the source links below:

Sources

https://sites.google.com/a/leighonline.net/clarification-through-obfuscation/clarification-through-obfuscation-news/_draft_post-3#

http://en.wikipedia.org/wiki/Swappiness

Categories: Uncategorized