From owner-freebsd-questions@FreeBSD.ORG Wed Jul 23 13:15:01 2014 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 08C967C5 for ; Wed, 23 Jul 2014 13:15:01 +0000 (UTC) Received: from mail-qa0-f54.google.com (mail-qa0-f54.google.com [209.85.216.54]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BAA8C29B0 for ; Wed, 23 Jul 2014 13:14:59 +0000 (UTC) Received: by mail-qa0-f54.google.com with SMTP id k15so1221124qaq.41 for ; Wed, 23 Jul 2014 06:14:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:content-type:mime-version:subject:from :in-reply-to:date:content-transfer-encoding:message-id:references:to; bh=hFBh/zdKsVLMqzS/M8YPzJQJ+UCqslRzRjnxhhjoPh4=; b=lLbhNjeva87Uig7bwE0zGVxkSeiAN5XuPzfjfCSb1fw3vx/waIryAZWulLqDDLgIMP V6dIbP/760lAb9PHQ9NaTGBbyYlGoy82GO5voFni3zpywPVKP4bSa6vPsYUwqDheX+7M HYm7QALNNNBbNw47EPH10WCpD9eDlVInX57mP3CN+WwfERhqXG2Nbaha2Nq/JiH2GRVb zo/UMi0DrPMJA54/VCLQsv1nnNHWM010YCMgBmVHLDs3Uyb/vzVE8TvjwEiadNo+oTZI lOAPtTQ3zj8Cl+IjO6QhCqGMDrFLNIp+K4cfoHA+xUZ5WpcoCFKNaIIJe1pNWqQE096k HONg== X-Gm-Message-State: ALoCoQl0fip8+wcuNNXaYZV3JDJFI68fDLQ0W0IoO1DaRkmybc9BfRugp0/dJxyg5fxUfEgF8aPi X-Received: by 10.224.43.196 with SMTP id x4mr1631006qae.63.1406119768719; Wed, 23 Jul 2014 05:49:28 -0700 (PDT) Received: from [192.168.2.65] ([96.236.21.80]) by mx.google.com with ESMTPSA id y79sm3120314qgy.18.2014.07.23.05.49.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Jul 2014 05:49:28 -0700 (PDT) Content-Type: text/plain; charset=windows-1252 Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) Subject: Re: How much swap space for a 32 GB RAM system? From: Paul Kraus In-Reply-To: <53CE8BB8.7030303@qeng-ho.org> Date: Wed, 23 Jul 2014 08:49:26 -0400 Content-Transfer-Encoding: quoted-printable Message-Id: References: <53CE8BB8.7030303@qeng-ho.org> To: FreeBSD-Questions X-Mailer: Apple Mail (2.1878.6) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Jul 2014 13:15:01 -0000 On Jul 22, 2014, at 12:05, Arthur Chance wrote: > I'm getting a new machine with 32 GB of memory. The old "twice = physical memory" sizing seems ridiculous, so how big should I make swap? = Do I even need swap with this much memory? Back to the original question=85 With a large amount of RAM (usually = defined as greater than 4GB), how much swap do I really need? I first started seeing that question back in about 1997 or 1998, but for = Solaris boxes that had grown to over 1GB RAM. At the time both RAM and = disk drives were expensive, and disk drives were typically 500MB (at the = largest). The rule of =93for servers configure 2+ times your RAM as = swap=94 and the rule for desktops was 1 to 1.5 times. This rule of thumb = was old then. The question then (as now) was why. Under SunOS 4.1 you could not run = the system without swap as the kernel allocated =93backing store=94 or = swap space for all (note that, ALL) memory allocated. This was because = RAM was a very limited resource and swapping was common, so having the = swap space allocated made sense. With the release of SunOS 5 (Solaris 2.x and later) the situation = changed and swap was no longer required*. You could run a Solaris 2 = system with NO swap configured. This was because Solaris 2 did not swap = in the traditional sense, it paged. In other words, entire processes = were not swapped out (the traditional meaning of the term to swap), = rather, as the system came under memory pressure, individual pages (8KB) = of RAM were paged out (but the device was still called the swap device). = If the system came under enormous memory pressure, then entire processes = would be swapped out. Chapter 13 of Adrian Cockcroft and Richard = Pettit=92s book, =93Sun Performance and Tuning=94 describes this quite = clearly for SunOS version prior to 5.7 (Solaris 7), when the memory = management sub-system was completely rewritten. The question for FreeBSD has to go back to how memory is managed and how = swap space is used (ignoring the crash dump function). I have not seen = anyone post a good description of how memory management works under = FreeBSD and I do not have the coding skills to just =93read the source=94,= so if someone reading this wrote that code or understands it, I would = love to have a really good detailed description to help make decisions = about RAM and swap. My largest FreeBSD system has 32GB of RAM and I have 32GB of swap = configured, but that is the exception not the rule. I have a much = smaller server I am building right now that has 16GB and only 8GB swap. = Remember to use multiple swap partitions and match the sizes. * The exception, and one that was not well documented, was the use of = Shared Memory under Solaris, at least up through Solaris 10. For every = page of shared memory allocated a page of swap space is allocated as = well. I do not know why, but that is the way it worked. I had a very = large (at the time) Oracle DB server have really weird issues because we = had very little swap (enough to hold the kernel in a crash dump) and = were trying to use multiple GB of shared memory. -- Paul Kraus paul@kraus-haus.org