Date: Thu, 1 Aug 2002 13:50:08 +0930 From: Greg 'groggy' Lehey <grog@FreeBSD.org> To: Rob Ellis <rob@web.ca> Cc: freebsd-questions@freebsd.org Subject: Re: 1GB ram, how much SWAP? Message-ID: <20020801042008.GD48188@wantadilla.lemis.com> In-Reply-To: <20020731211506.GN22253@web.ca> References: <20020731171728.GH22253@web.ca> <87u1mfk9me.fsf@pooh.int> <20020731194842.GL22253@web.ca> <44ado7ejh7.fsf@be-well.ilk.org> <20020731211506.GN22253@web.ca>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wednesday, 31 July 2002 at 17:15:07 -0400, Rob Ellis wrote: >>> the consensus seems to be that if you want to be able to get >>> crash dumps, you need a single partition == to your memory >> >> 64k more than your memory, actually... > > there was some disagreement about that in that freebsd-hackers thread: > > http://www.FreeBSD.org/cgi/getmsg.cgi?fetch=268723+271430+/usr/local/www/db/text/2002/freebsd-hackers/20020714.freebsd-hackers For some reasons, I don't see the followup to these messages. In order to take a dump, you need space for the dump and also space for header information. I'm pretty sure that the headers need nothing like 64 kB, but I haven't had time to go and look at the code, and what's 64 kB when we're talking about at least 1 GB of swap. Note also that the dump gets written at the end of the swap partition, so if you have more swap, the dump can survive a little swapping without getting overwritten. >>> in the meantime, 1GB ram + .5GB swap still seems like lots? >> >> Depends on how much virtual address space you're using at once. > > yes. it would be nice to know ballpark requirements for different > types of servers / what kind of capacities you get with freebsd > and various hardware configurations. I'm attaching a text version of part of a chapter of the upcoming new edition of "The Complete FreeBSD", in text form. You'll notice that my recommendation was 1 MB more than the size of memory. I'd welcome feedback. Greg -- When replying to this message, please copy the original recipients. If you don't, I may ignore the reply. For more information, see http://www.lemis.com/questions.html How much swap space? ____________________ Apart from files, you should also have at least one swap partition on your disk. It's very difficult to predict how much swap space you need. The automatic option gave you 522 MB, slightly more than twice the size of physical memory. Maybe you can get by with 64 MB. Maybe you'll need 2 GB. How do you decide? It's almost impossible to know in advance what your system will require. Here are some considerations: o Swap space is needed for all pages of virtual memory which contain data that is not locked in memory and which can't be recreated automatically. This is the majority of virtual memory in the system. o Some people use rules of thumb like ``2.5 times the size of physical memory, or 64 MB, whichever is bigger''. These rules work only by making assumptions about your workload. If you're using more than 2.5 times as much swap space as physical memory, performance will suffer. o Known memory hogs are X11 and integrated graphical programs such as Netscape and StarOffice. If you use these, you will probably need more swap space. Older UNIX-based hogs such as Emacs and the GNU C compiler (gcc) are not in the same league. o You can add additional swap partitions on other disks. This has the additional advantage of balancing the disk load if your machine swaps a lot. o About the only ways to change the size of a swap partition are to add another partition or to reinstall the system, so if you're not sure, a little bit more won't do any harm, but too little can really be a problem. o If your system panics, and memory dumping is enabled, it will write the contents of memory to the swap partition. This will obviously not work if your swap partition is smaller than main memory. Under these circumstances, the system refuses to dump, so you will not be able to find the cause of the problems. The dump routines can only dump to a single partition, so you need one that is big enough. If you have 512 MB of memory and two swap partitions of 384 MB each, you still will not be able to dump. o Even with light memory loads, the virtual memory system slowly pages out data in preparation for a possible sudden demand for memory. This means that it can be more responsive to such requests. As a result, you should have at least as much swap as memory. A couple of examples might make this clearer: 1. Some years ago I used to run X, StarOffice, Netscape and a whole lot of other memory-hungry applications on an old 486 with 16 MB. Sure, it's really slow, especially when changing from one application to another, but it works. Since there's not much memory, it uses a lot of swap. To view the current swap usage, use pstat. Here's a typical view of this machine's swap space: $ pstat -s Device 1024-blocks Used Avail Capacity Type /dev/da0s1b 122880 65148 57668 53% Interleaved 2. Later, I ran much more stuff on an AMD Athlon with 256 MB of memory. It had lots of swap space, but what I saw was: $ pstat -s Device 1024-blocks Used Avail Capacity Type /dev/ad0s1b 524020 22328 501692 4% Interleaved It's not so important that the Athlon is using less swap: it's using 9% of its memory in swap, whereas the 486 is using 4 times its memory. In a previous edition of this book, I had the example of a Pentium with 96 MB of memory, which used 43 MB of swap. Look at it from a different point, and it makes more sense: swap makes up for the lack of real memory, so the 486 is using a total of 80 MB of memory, the Pentium is using 140 MB, and the Athlon is using 280 MB. In other words, there is a tendency to be able to say ``the more main memory you have, the less swap you need''. If, however, you look at it from the point of view of acceptable performance, you will hear things like ``you need at least one-third of your virtual memory in real memory''. That makes sense from a performance point of view, assuming all processes are relatively active. And, of course, it's another way of saying ``take twice as much swap as real memory''. In summary: be generous in allocating swap space. If you have the choice, use more. If you really can't make up your mind, take 512 MB of swap space or one MB more than the maximum memory size you are likely to install. -- When replying to this message, please copy the original recipients. If you don't, I may ignore the reply. For more information, see http://www.lemis.com/questions.html See complete headers for address and phone numbers 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?20020801042008.GD48188>