
274
|
Chapter 10, Kernel
#91 Tweak Your Kernel Without Recompiling
HACK
desktop. If you’re running one of the later 2.6 kernels, this pack of hacks
includes a few tricks you can use to modify the performance of the kernel
you already have installed and running.
One of the most hotly debated performance topics is how Linux should
determine what memory to swap to disk, how much it should swap, and
when to do it. The answer is simple. Use one or more of the following
tweaks to control this process yourself.
Setting Swappiness via /proc
A kernel parameter is available that is represented as a pseudofile called /proc/
sys/vm/swappiness. The default value for the parameter is 70. You can log in
and view the default value with this command:
# cat /proc/sys/vm/swappiness
70
The number is a rough gauge for how likely it is that Linux will swap to disk
whatever it considers to be swappable. If you set it to 100, it will swap most
aggressively. If you set it to 20, it will tend to swap a lot less. Here is how
you can set it to either value (logged in as root):
# echo "100" > /proc/sys/vm/swappiness
# cat /proc/sys/vm/swappiness
100
# echo "20" > /proc/sys/vm/swappiness
# cat /proc/sys/vm/swappiness
20
The argument for either side goes like this. Set the swappiness value to a
high number, even to 100, if you run several bloated applications and do not
often switch between them. The end result will be that when you do ...