From owner-freebsd-performance@FreeBSD.ORG Wed Apr 30 16:19:07 2003 Return-Path: Delivered-To: freebsd-performance@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 71FD337B404 for ; Wed, 30 Apr 2003 16:19:07 -0700 (PDT) Received: from stork.mail.pas.earthlink.net (stork.mail.pas.earthlink.net [207.217.120.188]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8177F43FBF for ; Wed, 30 Apr 2003 16:19:06 -0700 (PDT) (envelope-from tlambert2@mindspring.com) Received: from pool0429.cvx40-bradley.dialup.earthlink.net ([216.244.43.174] helo=mindspring.com) by stork.mail.pas.earthlink.net with asmtp (SSLv3:RC4-MD5:128) (Exim 3.33 #1) id 19B0qm-0007er-00; Wed, 30 Apr 2003 16:18:57 -0700 Message-ID: <3EB05944.B66F13D@mindspring.com> Date: Wed, 30 Apr 2003 16:16:20 -0700 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Adrian Filipi-Martin References: <200304281054.48976.ryba@kompakt.pl> <20030430174616.E59039@lorax.ubergeeks.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-ELNK-Trace: b1a02af9316fbb217a47c185c03b154d40683398e744b8a420d75dc81dcda64c9ebf8e47e13f47b33ca473d225a0f487350badd9bab72f9c350badd9bab72f9c cc: freebsd-performance@freebsd.org cc: Michael Nottebrock Subject: Re: SWAP size X-BeenThere: freebsd-performance@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Performance/tuning List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Apr 2003 23:19:07 -0000 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 grown. 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. -- Terry