06 October 2007

Why Linux Feels Slow and How To Fix That

You'll want to read the whole article but here is the condensed version:

Swappiness is the name Linux kernel developers gave to the preference between paging applicatios out to disk and (in practice) shrinking caches. If it’s close to 0, Linux will prefer to keep applications in RAM and not grow the caches. If it’s close to 100, Linux will prefer to swap applications out, and enlarge the caches as much as possible.

OK, let’s tune swappiness. In a console as root, run:

sysctl -w vm.swappiness=1

To make the change permanent, write vm.swappiness=1 on your /etc/sysctl.conf file.

Also, we’ve already established that the filesystem cache is important because, without it, file browsing goes extremely slowly as well. Now we’ll learn how to tell Linux that we want it to prefer inode/dentry cache to other caches. In a root console run:

sysctl -w vm.vfs_cache_pressure=50

To make the change permanent, put vm.vfs_cache_pressure=50 on your /etc/sysctl.conf file.

Please experiment with this value. Values close to 100 provide no gain. Values close to zero can cause huge swap activity during big filesystem scans.

No comments: