Operating Systems > Linux and UNIX

WHats your Swap Size?

<< < (6/6)

DC:

quote:Originally posted by void main:


I believe you have less swap than what you should have. I think you want at least 128MB but very possible 512MB of swap as the minimum. And swap space is there to help speed things up, not slow them down. Without swap space, RAM can not be used for efficient caching.

I also have 512MB of RAM and 512MB of swap. At this second I am showing ~65MB of RAM free, and ~56MB of swap used. I certainly don't have 450MB of program code running. A lot of my RAM is being used for caching which makes things faster. Some memory has been paged out to swap because it isn't being used so there is more RAM available for cache. At least that's the way I understand how the swap works. Add more swap and let your system do it's magic.
--- End quote ---


Err... ooops. No idea how that 0 got lost in that post    (should be 500MB, corrected it)

Swap is not there to speed up things. Swap is there to let you run stuff that you would normally be unable to do due to lack of RAM. RAM can be used for efficient catching without swap - the ONLY case in which you need swap if you need x MB of mem and have x-n RAM (n=positive number). In that case, some mem is paged to disk to free up RAM for programs that need it more. This is SLOW, since disk is about 10000x as slow as RAM, so it can't possibly speed things up.
With enough mem, swap is simply not used and has no effect on the system whatsoever.

Anyway, I have yet to see swap usage go beyond 20 MB. As I said, swap is only used during real intensive usage, and I think it isn't really neccesary even then.

voidmain:

quote:Originally posted by DC:
Swap is not there to speed up things. Swap is there to let you run stuff that you would normally be unable to do due to lack of RAM. RAM can be used for efficient catching without swap - the ONLY case in which you need swap if you need x MB of mem and have x-n RAM (n=positive number). In that case, some mem is paged to disk to free up RAM for programs that need it more. This is SLOW, since disk is about 10000x as slow as RAM, so it can't possibly speed things up.
With enough mem, swap is simply not used and has no effect on the system whatsoever.

--- End quote ---


That's what I used to think but it's not true that swap is only there to let you run programs that normally won't fit into memory. RAM is also used for file system caching, etc. Even if you have free RAM the system will swap unused program data to make more room for cache which will speed things up considerably if you do a lot of IO. It is true that if you do not have enough RAM to even hold the program code that you need to run your system will get very slow due to constant paging (and even worse if it is thrashing).

With 512MB of RAM it is very possible that you have enough that no swapping will occur and that is certainly optimal. But I also have 512MB of RAM and I usually have at least 100MB of swap in use. For instance, I just rebooted my desktop a little while ago and now I only have 312MB of my 512MB of physical RAM used and no swap. But last night I had over 400MB used and around 100MB of swap in use because over time things got cached in RAM and getting cache hits are much faster than having to grab things from disk again.

You also need to look at your "cached" and "buffered" stats. As soon as I start doing some more large data tasks more will get cached and some swapping will occur, even if my RAM is not 100% full. It will only swap portions that will not have a detrimental effect on performance (as long as I have enough RAM for that to happen). Making more room in RAM for cache will *increase* performance. Read over the Linux VM logic. Actually, here's a pretty good chapter in a performance tuning book that talks about Linux and Solaris swap setup, swapping and paging:

http://www.oreilly.com/catalog/spt2/chapter/ch04.html

[ November 12, 2002: Message edited by: void main ]

Navigation

[0] Message Index

[*] Previous page

Go to full version