30 January 2012

Linux: about swap


I can't even begin to count how many time I've heard this argument: "You don't really need swap space as in an ideal situation your system shouldn't be swapping anyhow."

Well...*sigh*... no.

Linux has this little cool thing called swapiness; it's a number between 0 and 100, basically telling Linux how fast it should swap out unused applications.
That's right: how fast... not if.
Setting swapiness to 0 will result in Linux avoiding swapping out stuff as long as possible, turn it up to 100 and Linux will swap out agressively, trying to have as much free physical memory available at all time.
Everything in between 0 and 100... well, you get the picture.

Swapping out stuff is a good thing!
I'm not going to start a crusade to set swapiness to 100, but c'mon... don't tell me an application running 24/7 but only occasionally actually doing something should keep all its data in physical memory.
I like the idea of Linux swapping it out to disk, freeing valuable and expensive physical memory for something important in need of fast memory space.
Have a look on your system right now, do a  cat of /proc/sys/vm/swappiness.
I'm willing to bet it's not set to 0.

What I'm trying to say here is swap is a cool system, but it depends on what you're building.
Some systems can benefit greatly of having swap space at their disposal, sometimes you just want to run everything in RAM all the time.

Oh and btw: not having swap space at all is fucking retarded (we're talking desktops and servers here, not embedded stuff).

No comments:

Post a Comment