[LeapList]Swapiness
Phil Barnett
leaplist@lists.leap-cf.org
Sat May 1 09:53:03 2004
There's been an interesting thread on the lkml about swapping in the kernel
and how to change the way it works. You can nearly eliminate swapping by
running: (Kernel 2.4.25 and up)
echo 0 > /proc/sys/vm/swapiness
and you can maximize swapping by running:
echo 100 > /proc/sys/vm/swapiness
So, why does this matter? Have you ever noticed that the cron jobs that run
each morning that update the locate process have pushed all of your desktop
apps out of memory and then you have to wait while each one swaps back into
main memory from the disk the first time you run it? You can eliminate this
behavior by substuting the following shell script for the one that runs
updatedb currently.
old=`cat /proc/sys/vm/swapiness`
echo 0 >/proc/sys/vm/swapiness
updatedb
echo $old >/proc/sys/vm/swapiness
There's lots of things we can do with this.
Andrew Morton keeps his swapiness at 100. It makes your computer run more
efficiently, but at a sacrifice of possibly having latency in your desktop
applications. Others have resorted to pushing this to 0 so the kernel never
swaps applications out of memory so there is little latency in recovering
desktop applications from swap.
Just my guess: Desktop users will find that a lower number is more
satisfactory. Servers admins will find that a higher number makes the server
more memory efficient because it will swap out all the stuff that runs once
during bootup and is never used again.
So, try different settings and see how you benefit most.
--
"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it." - Brian W. Kernighan