Subject: RE: swap partition (was: uvm_faults)
To: None <claude.marinier@dreo.dnd.ca, Markus.Mueller@itworks-gmbh.de>
From: None <eeh@netbsd.org>
List: netbsd-help
Date: 12/11/2001 18:00:34
|
| A friend of mine told me I should set the swap partition twice as big as 
| the RAM, he always seemed to do this...
|
| I'm still a rookie with this stuff, so I listen to any advice I get...   

While this was once true, it is no longer the case.

Originally (pre-VAX) unix would swap entire processes in and out of
memory.  That means none of the image could be RAM-resident and you 
needed to have enough disk space to store the entire process image 
before it could be executed.  But with 64KB RAM that wasn't a big
issue.  

When the VAX came along with a real MMU and demand paging was 
implemented, machines still had small RAM footprints (say 4MB)
and swap was still allocated when processes were started.  RAM
was simply a cache for swap space on disk, so if your swap space
wasn't larger than the amount of RAM on that machine you couldn't
even use all of RAM.

With 4.4BSD (and SVR4 which uses the Sun VM system) that all changed.
Machines now began to have larger amounts of RAM and and swap was
allocated as-needed.  RAM itself now counts as swap space (hey, 
guess what, a page of RAM can actually hold a page of data!)  This 
allows you to run without any swap space at all.

So now instead of 2x RAM, you should calculate the maximum size 
of workload you think you will run (say 5 copies of emacs at 6MB 
each) add in the size of any tmpfs or ramdisks you expect to use,
and make sure the sum of RAM and swap exceeds that.  You probably
want to add 20-30% slop because the kernel overcommits and you
don't want to hang the system if you're on the edge of swap use.

Eduardo