tlambert2 at mindspring.com
Wed Apr 30 16:19:07 PDT 2003
Adrian Filipi-Martin wrote:
> On Mon, 28 Apr 2003, Michael Nottebrock wrote:
> > On Monday 28 April 2003 10:54, Piotr Rybicki wrote:
> > > 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.
> 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.
1) Memory overcommit
Because memory can be overcommitted, as of BSD's adoption
of the Mach VM, the amount of swap that's recommended has
2) Aggressive caching
Because FreeBSD aggressively caches data, it would prefer
to swap out dirty pages which have not been used for a
long time, than to throw away clean pages that have been
used recenty. Historical implementations would throw
away clean pages to avoid swapping, and only when they
were out of them, would they actually start swapping (or
when a clean page was faulted in very recently). The
amount of recommended swap is higher because of this, as
the more swap you have, the better your cache locality,
and the better this policy operates.
So it's grown from "as much swap as you feel you need" to "as much
swap as you have RAM" to "1.5 times RAM" to "2x RAM".
All in all, it's just a rule of thumb; however, there are some
consequences to not following it, for each time things have
changed, the consequences get more and more dire. 8-).
This is why people don't give much creedence to the people who
are trying to run without swap; we're willing to help them track
down things that make it impossible, but we recognize that just
because something's possible doesn't mean it's a good idea.
More information about the freebsd-performance