Jin Guojun [DSD]
j_guojun at lbl.gov
Wed Apr 30 16:00:24 PDT 2003
Adrian Filipi-Martin wrote:
> On Mon, 28 Apr 2003, Michael Nottebrock wrote:
> > On Monday 28 April 2003 10:54, Piotr Rybicki wrote:
> > > Hi everyone.
> > >
> > > In man tuning(7) we read, that swap size should be about 2x main memmory
> > > size. Why swap size should be so big? Isn't swap size equal to main memmory
> > > size enough?
> > IMHO the swapsize=2x phys. mem size has always been just a rule of thumb. You
> > need as much swap as you need (doh). But so far, the memory requirements of
> > software have pretty much grown proportionally with the availibility /
> > affordability of bigger sticks of memory and thus the rule of thumb still
> > makes sense. YMMV.
> > --
> > Regards,
> > Michael Nottebrock
> It used to mean something. 1x for swapping (whole processes) and
> 1x for paging (just pages of a process). Each portion was used for exactly
> one purpose. This is no longer a valid reason though. IIRC, it is because
> FreeBSD has a unified buffer cache.
> I don't know if there are any other reasons for 2x. I don't bothe
> with more than 1x personally, if that much. Swap space is really there for
> emergencies only IMHO.
This was a simple math for large process swap.
If you have big processes that take the all available memory (95%),
how do you swap them?
You need to swap out one to a disk space that has 95% memory size,
where there other one must reside on another disk space having the same size.
95% x 2 = 190% --> 200%
That is the only reason for 2X, so two big process can be swapped.
The original SWAP space was 2.5x, because the 0.5x was for backing
up other small processes in case there are two big processes running.
What is the best size? It really depends on the maximum total memory
needed for all possible applications the machine will run.
Theoretically, it can be zero if it is your desktop machine that never runs
out of memory. This is the best performance you can get.
Or, it can be as big as you need
(tuning says "If you do not have a lot of RAM, though ...")
(1) no money to buy more RAM,
(2) no slot to put more RAM
(3) it is a server just favor by every user to run their programs.
Swap space is prepared for too many processes outrunning the RAM.
It is not for improving performance, but exchange cost of disk for RAM.
More swap space required means that more swap time means slow.
Compare 256MB RAM + 512MB SWAP with 512 MB RAM + 0 SWAP,
I think the later works better because if two processes cannot coexist in
512 MB RAM, they will not run on a 256MB system simultaneously any way.
If you have a lot of memory and you are able to control all processes
not to overrun the system memory, 0.5 - 1x swap is OK; you need some
swap space to back up yourself in case something happens.
That is why 2x is recommended; but not required if this is not a server.
For server, 2x may be required, and typically 2.5x is needed.
------------ Jin Guojun ----------- v --- j_guojun at lbl.gov ---
Distributed Systems Department http://www.itg.lbl.gov/~jin
M/S 50B-2239 Ph#:(510) 486-7531 Fax: 486-6363
Lawrence Berkeley National Laboratory, Berkeley, CA 94720
More information about the freebsd-performance