From owner-freebsd-performance@FreeBSD.ORG Wed Apr 30 16:00:23 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 DD27937B420 for ; Wed, 30 Apr 2003 16:00:23 -0700 (PDT) Received: from postal2.lbl.gov (postal2.lbl.gov [131.243.248.26]) by mx1.FreeBSD.org (Postfix) with ESMTP id 08A2543FA3 for ; Wed, 30 Apr 2003 16:00:22 -0700 (PDT) (envelope-from j_guojun@lbl.gov) Received: from postal2.lbl.gov (localhost [127.0.0.1]) by postal2.lbl.gov (8.12.9/8.12.9) with ESMTP id h3UN0LCW007426 for ; Wed, 30 Apr 2003 16:00:21 -0700 (PDT) Received: from lbl.gov (gracie.lbl.gov [131.243.2.175]) by postal2.lbl.gov (8.12.9/8.12.9) with ESMTP id h3UN0L1b007423; Wed, 30 Apr 2003 16:00:21 -0700 (PDT) Sender: jin@lbl.gov Message-ID: <3EB05582.297F50AE@lbl.gov> Date: Wed, 30 Apr 2003 16:00:18 -0700 From: "Jin Guojun [DSD]" X-Mailer: Mozilla 4.76 [en] (X11; U; FreeBSD 4.7-RELEASE i386) X-Accept-Language: zh, zh-CN, 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-Content-Filtered-By: Mailman/MimeDel 2.1.1 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:00:24 -0000 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. > > Adrian 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 ...") if (1) no money to buy more RAM, (2) no slot to put more RAM or (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. Summary: 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@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