From owner-freebsd-current Mon Oct 28 16:16:06 1996 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id QAA19536 for current-outgoing; Mon, 28 Oct 1996 16:16:06 -0800 (PST) Received: from dyson.iquest.net ([198.70.144.127]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id QAA19529 for ; Mon, 28 Oct 1996 16:16:02 -0800 (PST) Received: (from root@localhost) by dyson.iquest.net (8.8.2/8.6.9) id TAA00994 for current@freebsd.org; Mon, 28 Oct 1996 19:16:00 -0500 (EST) From: "John S. Dyson" Message-Id: <199610290016.TAA00994@dyson.iquest.net> Subject: Request to add this to FAQ re: swap space To: current@freebsd.org Date: Mon, 28 Oct 1996 19:16:00 -0500 (EST) Reply-To: dyson@freebsd.org X-Mailer: ELM [version 2.4 PL24 ME8] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk This is some basic info that I would like to see added to the FAQ someday... Also, someone who knows English better than me (like one of our non-native English speaker European friends), might want to clean up the syntax!!! :-). This is a more accurate (and wordy) description of our swap space allocation reqs: How much disk should I allocate for swap? Each OS has different algorithms for swap memory allocation. FreeBSD takes maximum advantage of available RAM by fairly agressively pushing seldom used pages out to disk. The algorithm that is used by FreeBSD also requires that every anonymous page in a process be backed by an equivalent amount of swap space. Additionally, due to the way that the algorithm works, the swap space needs to be at least as a very minimum, the size of physical ram. But, ignore that statement, because in practical terms, the minimum amount of swap space should be MUCH larger... Some will quote a magic formula like swap space needing to be 2X RAM or somesuch. Well, that is sometimes low also. In fact, imagine an 8MB machine running X windows, with a couple copies of Netscape!!! (I know that it isn't a pretty sight, but imagine it anyway.) That machine will easily use up 16MB of swap space and more. On FreeBSD, the consequences of using up swap space are "not nice." It doesn't usually cause a system crash, but what the system does do is to try to protect itself by killing off processes, largest first. The best formula to use is to calculate the size of all of the processes that you plan to run, and use that value (with a practical minimum of 2 times RAM.) Figure that a heavily used X windows workstation can easily use 100MB of swap space or more. A moderately used X windows workstation, even though it is idle alot of the time, can easily use 30MB of swap for no apparent reason. The actual reason is that at one time or another, someone has run some large processes, or perhaps alot of pages are just sitting around idle, and the system has pushed them out. When the pages are brought into memory, the space that they use is not reclaimed. That is a performance optimization (however minor.) It isn't very easy to apriori determine the amount of swap space that the system will require, but frankly a single user workstation should be configured with at least 30MB of swap, and 50MB of swap is alot more comfortable. And remember, you need swap space for every anonymous page in a process. For a server application, the best thing to do is to simply measure the virtual size of each process by using ps and sum them. That measurement isn't entirely accurate, but shows the order of magnitude of needed swap space. So, to make it simple: swap-space = min(2*RAM, sum of the sizes of all processes); as usual, add some space in for expansion and for process growth. John