Jeff Abrahamson on 15 May 2006 20:49:20 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] vmstat and swapping out pages; need more RAM?


On Mon, May 15, 2006 at 04:31:35PM -0400, bergman@merctech.com wrote:
>   [62 lines, 372 words, 2436 characters]  Top characters: eaotnsir
> 
> 
> 
> In the message dated: Mon, 15 May 2006 16:10:47 EDT,
> The pithy ruminations from Jeff Abrahamson on 
> <Re: [PLUG] vmstat and swapping out pages; need more RAM?> were:
> => 
> 
> => 
> => On Mon, May 15, 2006 at 03:59:01PM -0400, Douglas Muth wrote:
> => > It looks like there is a lot of swap space being used, even though
> => > you look okay on RAM.
> => 
> => Remember that a good VM system will actually *use* swap space, though
> => what it uses it for is another question with a long answer on which
> => reasonable people might disagree.  If you aren't using swap, you have
> => a bad VM system or you aren't do anything and have a tiny kernel.
> 
> Care to expand on that? I'm really interested in getting some more details.
> 
> I'd say that:
> 	a good memory management system will actually *use* virtual memory
> 	(where virtual memory = (RAM + swap))...if you aren't using [almost]
> 	all of your RAM you aren't doing anything and have a tiny kernel.
> 
> However, if the VM is swapping processes to disk in order to use RAM
> for anything other than running other processes (ie., for filesystem
> buffering), I'd say it's not a well-behaved VM. If the VM is
> swapping processes to disk in order to use RAM for running other
> processes, then you need more RAM.

The VM does more than just move things to and from swap.  It maintains
the address translations that allow process to think they all start at
0x00000000, for example.  When a program runs, VM memory maps the
binary and its libraries so that you can page fault them into memory
as you use them.  When code pages fault into memory, they might
displace something else or they might not.  Code pages generally don't
get marked dirty (needing to be written out again), they're just
discarded if they are replaced.

None of this uses swap space.  You generally care only when the work
from page faulting approaches a significant fraction of the work you
really care about.

The VM system should provide all but a very small bit of code by this
mechanism.  It really depends on how often things are moving in and
out whether you care.  If crond is sleeping until six hours from now,
it's just fine that it's not memory resident and it's just fine by
most reckonings that it will swap in when its alarm goes off and it
needs to run.


> => What's bad, though, is things going in and out of swap too often.
> 
> If you've got the capacity and $$ to expand RAM, then I define "swap
> too often" as "swap at all".
> 
> My personal idea of a good balance: all the RAM is used, and swap
> space doesn't get touched for 80+% of normal usage.

OK, you want to have enough room to have the kernel, all of its
modules, all of your applications, all of your data, in memory without
anything active ever faulting out?  It's just a resource trade-off.
But it may not give you the performance boost you're looking for if
you are only avoiding once every few second faults.  If you are seeing
tons of page faults every millisecond, that might be a different
story.

-- 
 Jeff

 Jeff Abrahamson  <http://jeff.purple.com/>          +1 215/837-2287
 GPG fingerprint: 1A1A BA95 D082 A558 A276  63C6 16BF 8C4C 0D1D AE4B

Attachment: signature.asc
Description: Digital signature

___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug