Skip to main content
Welcome guest. | Register | Login | Post

What's your swappiness?

14 replies [Last post]
libervisco's picture
Offline
Joined: 2006-05-04

I was wondering if there is a way to reduce the use of swap in GNU/Linux so that it doesn't put anything in swap as long as it still has real memory left. After searching I found out about "swappiness" setting for the Linux kernel.

Basically it is a setting between 0 and 100 set in /proc/sys/vm/swappiness and can be set permanently by doing sysctl -w vm.swappiness=30 where 30 is your swappiness value.

If your swappiness is 0 it will not swap at all until the real memory is full. If it is set to 100 it will swap a lot. Not to rant too much about it myself here is a link to an extensive discussion about what is the best way: Linux: Tuning Swappiness.

Reading just a few first post will give you the idea of what is it and what is the effect of lower vs. higher setting.

Now, it seems the default in Linux, as well as it is set in Ubuntu is 60. Has anyone tweaked this and what were your experiences? Did you gain any performance improvements by setting it lower or higher? It seems to be a tradeoff which depends from user to user and how they use their computer..

libervisco's picture
Offline
Joined: 2006-05-04
I tested a bit, but didn't

I tested a bit, but didn't notice big improvements when putting swappiness on 0 (and 100 would probably be even worse) so I left it at the middle; 50. Smiling

tbuitenh's picture
Offline
Joined: 2005-12-21
Here on archlinux it's also

Here on archlinux it's also 60. Since my computer never swaps during normal use (I have multiple times more memory than my lightweight configuration needs), adjusting the swappiness is meaningless for optimization.

Offline
Joined: 2006-03-28
I'm running an LFS and I

I'm running an LFS and I couldn't find any bootscript setting this, so I guess that's the default value.
I have 1GB of RAM and didn't see my system swapping, even when doing my test-compiles of my distro.
Right now my swap is totally empty. As some sort of "proof of swapping" I've seen a few times that a few KBs or maybe even a few MBs (but for sure less than 20MB) were used in swap, but that's it.
I would have to check if I can see some bigger swapping with some killer-compiles like KDE-Base or Firefox, but I don't think there will be a great deal of swapping.
Another test might be starting lots of apps and then starting a game or rendering an animation with Blender.

Will have to check on how to get my system put a big chunk of data in swap, so far I haven't seen this.

libervisco's picture
Offline
Joined: 2006-05-04
Lucky you. I have 256MB

Lucky you. Smiling

I have 256MB real RAM only so it does tend to swap. I wont be buying more RAM till I can buy new MBO and CPU as well because the current box doesn't support DDR2 and the older types of memory are deliberately overpriced to push them out of the market (so says the salesman).

Offline
Joined: 2006-03-28
I'll play around a little

I'll play around a little tonight to see if it does some more swapping when I set it to 100.

Just wanted to check here in the office, on my Debian-server, but this is running Linux 2.4 and this one doesn't have the swappiness-setting yet.

But I think that, with desktops having more and more RAM nowadays, swapping becomes more or less obsolete. As said before, I hardly see any swapping on my box. When more memory is needed it usually reclaims some from the disc-cache and uses that. So I will try around and see how I can really make it swap big-time, and also try around a little with the swappiness-setting.

AndrewB's picture
Offline
Joined: 2005-12-18
This looks pretty cool. I

This looks pretty cool.
I will play about on my Ubuntu server when I get home. I have 768mb ram (512+256). I don't use the system for much. So I don't tend to swap.
Only things running there are..
yasuc,
mpd,
irssi,
apache,
sshd,
mysqld.
How ever sometimes I run SETI@home and this does use alot of system resources. Maybe swappiness will help that!

My main box [x86] only has 512mb ram. It doesn't run X so it has no problems, also CRUX is so optomised it wouldn't effect it!

Will maybe try on the mac..as soon as I sort it out and fix it all.

Offline
Joined: 2006-03-28
Okay, I ran a few little

Okay, I ran a few little tests now. I set swappiness to 100 and started a bunch of apps. No swapping.
But I could finally get some swapping by rendering a pretty memory-hungry picture in Blender. That way I my swap filles up to nearly 100MB.
Now I will clear the swap and retry with swappiness 60 to see what will happen.
I'll let you know...

Offline
Joined: 2006-03-28
Okay, with swappiness at 60

Okay, with swappiness at 60 it also swaps, and it as more or less the same amount of memory that gets swapped out.
But so far it seems to me that more or less the only application that can make my system swap is Blender. Maybe also Gimp if I open lots of highres pictures (which I usually don't do).
I guess when I update my system next time (means when I go on an AMD64) swap might really not be necessary anymore (although I'll still keep a GB or maybe two) since I plan to also double my RAM to 2GB.

libervisco's picture
Offline
Joined: 2006-05-04
Cool. Looks like with 1 GB

Cool. Looks like with 1 GB RAM swap is rarely even needed (not everyone runs blender). You could probably just put it to 0 and still be safe. Smiling

I'll have to get a new MBO and CPU this year so I can expand my RAM as well.. (and getting only MBO and CPU is cheaper than getting a whole new comp).

Offline
Joined: 2006-03-28
Buying parts...
libervisco wrote:

(and getting only MBO and CPU is cheaper than getting a whole new comp).

That's why I also always just by parts. Anyway, my case was expensive enough and it looks quite cool, so I still want to use it for a couple of years.
But I should really open it up and blow all the dust out of the fans...

free-zombie's picture
Offline
Joined: 2006-03-08
I've been using swappiness

I've been using swappiness = 100 for the last ~30 min while compiling openoffice 2.1.0 and it's swapped 153MB. I didn't notice any lag or anything when I returned to the computer just now... (1GB of RAM)

a thing's picture
Offline
Joined: 2005-12-20
10

I played with this a bit, and I settled with 10. Now Firefox is more responsive.

Offline
Joined: 2005-12-20
I never swap, well, never

I never swap, well, never more than 5mb, and that's only when compiling. I have 1024mb of RAM, so I guess that's why. I never even touch anywhere near 700mb of it, even with KDE + Firefox (with 15 tabs) + irssi + amarok + konqueror and more. Usually I use evilwm though, very nice, never use more than 200mb with that.

libervisco's picture
Offline