Skip site navigation (1)Skip section navigation (2)
Date:      08 Oct 2001 11:36:07 -0700
From:      swear@blarg.net (Gary W. Swearingen)
To:        Mike Meyer <mwm@mired.org>
Cc:        swear@blarg.net (Gary W. Swearingen), questions@freebsd.org
Subject:   Re: ideal swap partition space...
Message-ID:  <7ypu7ygeso.u7y@localhost.localdomain>
In-Reply-To: <15297.5510.364245.686083@guru.mired.org>
References:  <15297.5510.364245.686083@guru.mired.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Mike Meyer <mwm@mired.org> writes:
> Gary W. Swearingen <swear@blarg.net> types:
> > "default" <default013subscriptions@hotmail.com> writes:
> > > I'm curious about setting up the amount of space for the swap partition...
> > > is there any ideal amount for FreeBSD?
> > Yes. None.
> 
> Only under some conditions. If you want to get core dumps after a
> panic, then the dump device needs to be at least 64K bigger than
> memory. You might as well use that device for swap, as you can't use
> it for anything else while the system is running.

I consider that far from ideal. :-)


From Handbook 24.2.6. Tuning the FreeBSD VM system:

  You should have at least 2x the swap space as you have main memory,
  and possibly even more if you do not have a lot of memory.

The two-times rule, stated strictly, even for those who's programs fill
a small fraction of their RAM.  Continuing:

  If you want to be able to accommodate a crash dump, your first swap
  partition must be at least as large as main memory and /var/crash must
  have sufficient free space to hold the dump.

Disagrees with what Mike and dumpon(8) says (main mem + 64 KB).  (And
it looks like we need a new rule of thumb for /var too.)

> If you can't afford enough real RAM to hold everything, you'll have to
> swap. According to the tuning man page, "The kernel's VM paging
> algorithms are tuned to perform best when there is at least 2x swap
> versus main memory."

If one believes that and cares more about performance of the VM
algorithms (whatever that might mean, assuming the author knew) than
about the extra disk space, then >2x would be good advice.  It's a
good thing to discuss in the tuning man page, but I'd leave it out
of general advice because it doesn't seem important enough (if right).

If one doesn't need to page, then paging performance isn't an issue.

If one needs to page only 0.5x RAM, are we to believe that it makes
a performance difference if we have 1x or >2x swap?  I suspect that the
tuning(7) author didn't go into enough detail with the above statement
or didn't understand what "best" means.  Such things are usually much
too complex to state in one word.

Of course, with today's drives, people don't mind wasting huge chunks
of disk if there's the least possibility it might help performance.

Let's consider an extreme (but fairly commom these days) case:

I have 512 MB of RAM and never need more than 128 MB of virtual memory
and need my VM system to run as fast as possible and I won't set my
system up to dump core for debugging (or whatever).  Is my system
going to run faster with 1 GB of swap than with 512 MB or 256 or 128
or 64 or zero?  I'll admit the possibility, but find it doubtful enough
to assume that no swap would be just as fast as 2x or 10x swap.

With the same RAM but need for 768 MB of VM, I'd be just as comfortable
having 1x swap as 2x.


I suspect that "performs best at 2x" is only implying that the VM system
will, for example, page 1.8xRAM in 2xRAM swap faster than it pages
0.9xRAM in 1xRAM swap or something along those lines - some measure 
of efficiency, not raw speed, and the comparitive efficiency should be
of zero concern to the user who only needs to page 0.9xRAM.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7ypu7ygeso.u7y>