* [gentoo-amd64] Is swap need when there is 4g of ram? @ 2007-03-13 9:09 P.V.Anthony 2007-03-13 9:56 ` Hemmann, Volker Armin ` (2 more replies) 0 siblings, 3 replies; 19+ messages in thread From: P.V.Anthony @ 2007-03-13 9:09 UTC (permalink / raw To: gentoo-amd64 Hi, Is swap really needed when there is a 4g of ram? P.V.Anthony -- gentoo-amd64@gentoo.org mailing list ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-amd64] Is swap need when there is 4g of ram? 2007-03-13 9:09 [gentoo-amd64] Is swap need when there is 4g of ram? P.V.Anthony @ 2007-03-13 9:56 ` Hemmann, Volker Armin 2007-03-13 12:46 ` Joaquim Quinteiro Uchoa 2007-03-13 14:30 ` Duncan 2007-03-13 18:04 ` [gentoo-amd64] " Peter Humphrey 2 siblings, 1 reply; 19+ messages in thread From: Hemmann, Volker Armin @ 2007-03-13 9:56 UTC (permalink / raw To: gentoo-amd64 On Dienstag, 13. März 2007, P.V.Anthony wrote: > Hi, > > Is swap really needed when there is a 4g of ram? depends ;) but you don't need a swap partition. A swapfile is good enough and more flexible. -- gentoo-amd64@gentoo.org mailing list ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-amd64] Is swap need when there is 4g of ram? 2007-03-13 9:56 ` Hemmann, Volker Armin @ 2007-03-13 12:46 ` Joaquim Quinteiro Uchoa 2007-03-13 13:39 ` Hemmann, Volker Armin 2007-03-13 14:11 ` dustin 0 siblings, 2 replies; 19+ messages in thread From: Joaquim Quinteiro Uchoa @ 2007-03-13 12:46 UTC (permalink / raw To: gentoo-amd64 My 50 cents: A swap partition is always faster than a swap file. Not so much, but is faster. With 4GB of RAM is expected to find computers with lof of free space in hard disk. So: creating a 4GB of swap in a partition will give us a extra resource with little cust. Anthony is really right: it depends if you need swap. In a server with 30 users, problably not, even in the case where the access is simultaneous (by experience with servers with 2GB of RAM and 2GB of swap). But, in a desktop, it depends of applications running at the same time. I have 4 GB of RAM, and when emerging some large programs, I mount some part of memory (3GB) in /var/tmp/portage (using tmpfs). This acelerates the emerging process, and the only program I can't compile in this way is openoffice :(. When I'm using memory as a space to compile programs, the swap is used in some moments, if I'm using firefox (with 2 windows of 10 tabs each) and openoffice. So, in normal use, you probably don't need a swap. But, It will hurts in terms of disk space to create it? Probably not, so create and be prepared to large requests of memory :). This is my sugestion... 2007/3/13, Hemmann, Volker Armin <volker.armin.hemmann@tu-clausthal.de>: > On Dienstag, 13. März 2007, P.V.Anthony wrote: > > Hi, > > > > Is swap really needed when there is a 4g of ram? > > depends ;) > > but you don't need a swap partition. A swapfile is good enough and more > flexible. > -- > gentoo-amd64@gentoo.org mailing list > > -- []s Joaquim ------------------------------------------ (o_ Joaquim Quinteiro Uchoa //\ Consultor Linux e EaD U_/_ Linux User # 100534 ------------------------------------------ -- gentoo-amd64@gentoo.org mailing list ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-amd64] Is swap need when there is 4g of ram? 2007-03-13 12:46 ` Joaquim Quinteiro Uchoa @ 2007-03-13 13:39 ` Hemmann, Volker Armin 2007-03-13 14:28 ` Joaquim Quinteiro Uchoa 2007-03-13 14:11 ` dustin 1 sibling, 1 reply; 19+ messages in thread From: Hemmann, Volker Armin @ 2007-03-13 13:39 UTC (permalink / raw To: gentoo-amd64 On Dienstag, 13. März 2007, Joaquim Quinteiro Uchoa wrote: > My 50 cents: > > A swap partition is always faster than a swap file. Not so much, but is > faster. nope. That was only true for 2.2 and 2.4 kernels. One of the features of 2.6 is that swapfiles are not slower anymore. -- gentoo-amd64@gentoo.org mailing list ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-amd64] Is swap need when there is 4g of ram? 2007-03-13 13:39 ` Hemmann, Volker Armin @ 2007-03-13 14:28 ` Joaquim Quinteiro Uchoa 2007-03-13 14:35 ` Hemmann, Volker Armin 2007-03-14 23:00 ` Paul de Vrieze 0 siblings, 2 replies; 19+ messages in thread From: Joaquim Quinteiro Uchoa @ 2007-03-13 14:28 UTC (permalink / raw To: gentoo-amd64 Ok, new swapfiles are acessed as block, bypassing the filesystem: http://lkml.org/lkml/2005/7/7/326 In this way, with physical access, really doesn't matter if is a partition or a swapfile... In this situation, a swap partition is only more easy to manage (You don't need to create the file after the instalation proccess) and can be shared by several SOs in a same computer. But swapfiles can be more flexible (you can expand and move more easily). I think I will prefer swapfiles in future instalations :) 2007/3/13, Hemmann, Volker Armin <volker.armin.hemmann@tu-clausthal.de>: > On Dienstag, 13. März 2007, Joaquim Quinteiro Uchoa wrote: > > My 50 cents: > > > > A swap partition is always faster than a swap file. Not so much, but is > > faster. > > nope. That was only true for 2.2 and 2.4 kernels. One of the features of 2.6 > is that swapfiles are not slower anymore. > > -- > gentoo-amd64@gentoo.org mailing list > > -- []s Joaquim ------------------------------------------ (o_ Joaquim Quinteiro Uchoa //\ Consultor Linux e EaD U_/_ Linux User # 100534 ------------------------------------------ -- gentoo-amd64@gentoo.org mailing list ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-amd64] Is swap need when there is 4g of ram? 2007-03-13 14:28 ` Joaquim Quinteiro Uchoa @ 2007-03-13 14:35 ` Hemmann, Volker Armin 2007-03-14 23:00 ` Paul de Vrieze 1 sibling, 0 replies; 19+ messages in thread From: Hemmann, Volker Armin @ 2007-03-13 14:35 UTC (permalink / raw To: gentoo-amd64 On Dienstag, 13. März 2007, Joaquim Quinteiro Uchoa wrote: > Ok, new swapfiles are acessed as block, bypassing the filesystem: > > http://lkml.org/lkml/2005/7/7/326 > > In this way, with physical access, really doesn't matter if is a > partition or a swapfile... > > In this situation, a swap partition is only more easy to manage (You > don't need to > create the file after the instalation proccess) and can be shared by > several SOs in a > same computer. But swapfiles can be more flexible (you can expand and move > more easily). > > I think I will prefer swapfiles in future instalations :) > I have a (small) swap partition, and a big 'emergeny' swapfile - that is hardly ever used. -- gentoo-amd64@gentoo.org mailing list ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-amd64] Is swap need when there is 4g of ram? 2007-03-13 14:28 ` Joaquim Quinteiro Uchoa 2007-03-13 14:35 ` Hemmann, Volker Armin @ 2007-03-14 23:00 ` Paul de Vrieze 1 sibling, 0 replies; 19+ messages in thread From: Paul de Vrieze @ 2007-03-14 23:00 UTC (permalink / raw To: gentoo-amd64 [-- Attachment #1: Type: text/plain, Size: 559 bytes --] On Tuesday 13 March 2007, Joaquim Quinteiro Uchoa wrote: > Ok, new swapfiles are acessed as block, bypassing the filesystem: > > http://lkml.org/lkml/2005/7/7/326 > > In this way, with physical access, really doesn't matter if is a > partition or a swapfile... Except that for a swap partition all parts of it are certainly contiguous. Something that does not generally hold for swap files. Being contiguous could help the speed a bit. Paul -- Paul de Vrieze Gentoo Developer Mail: pauldv@gentoo.org Homepage: http://www.devrieze.net [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --] ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-amd64] Is swap need when there is 4g of ram? 2007-03-13 12:46 ` Joaquim Quinteiro Uchoa 2007-03-13 13:39 ` Hemmann, Volker Armin @ 2007-03-13 14:11 ` dustin 2007-03-13 14:32 ` Hemmann, Volker Armin 1 sibling, 1 reply; 19+ messages in thread From: dustin @ 2007-03-13 14:11 UTC (permalink / raw To: gentoo-amd64 On Tue, Mar 13, 2007 at 09:46:39AM -0300, Joaquim Quinteiro Uchoa wrote: > Anthony is really right: it depends if you need swap. In a server with > 30 users, > problably not, even in the case where the access is simultaneous (by experience > with servers with 2GB of RAM and 2GB of swap). One of the benefits of swap is that unused application text, data, etc. can be paged out in a fairly permanent fashion. Without swap, that stuff has to sit in RAM, even if it's not touched for hours or days. I'm not sure if your load is such that the savings will be a significant portion of 4G. Dustin -- gentoo-amd64@gentoo.org mailing list ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-amd64] Is swap need when there is 4g of ram? 2007-03-13 14:11 ` dustin @ 2007-03-13 14:32 ` Hemmann, Volker Armin 2007-03-13 20:24 ` Richard Freeman 2007-03-14 14:19 ` Jack Lloyd 0 siblings, 2 replies; 19+ messages in thread From: Hemmann, Volker Armin @ 2007-03-13 14:32 UTC (permalink / raw To: gentoo-amd64 On Dienstag, 13. März 2007, dustin@v.igoro.us wrote: > On Tue, Mar 13, 2007 at 09:46:39AM -0300, Joaquim Quinteiro Uchoa wrote: > > Anthony is really right: it depends if you need swap. In a server with > > 30 users, > > problably not, even in the case where the access is simultaneous (by > > experience with servers with 2GB of RAM and 2GB of swap). > > One of the benefits of swap is that unused application text, data, etc. > can be paged out in a fairly permanent fashion. Without swap, that > stuff has to sit in RAM, even if it's not touched for hours or days. > no it has not to stay in ram. Unused stuff that is not 'dirty' IE identical to the stuff on harddisk, can be kicked out of ram, when the space is needed. And for some funny reason, loading something out of swap is much slower than loading it from the fs.... 50mb in swap - and everything is slow. So slow as if every bit is fetched by a mule caravan. And it does not matter if it is a swap partition or a swap file. It is slow. But there is an easy way to get the box back to normal speed: swapoff -a && swapon -a ... -- gentoo-amd64@gentoo.org mailing list ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-amd64] Is swap need when there is 4g of ram? 2007-03-13 14:32 ` Hemmann, Volker Armin @ 2007-03-13 20:24 ` Richard Freeman 2007-03-14 14:19 ` Jack Lloyd 1 sibling, 0 replies; 19+ messages in thread From: Richard Freeman @ 2007-03-13 20:24 UTC (permalink / raw To: gentoo-amd64 [-- Attachment #1: Type: text/plain, Size: 2457 bytes --] -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hemmann, Volker Armin wrote: > And for some funny reason, loading something out of swap is much slower than > loading it from the fs.... That seems odd. if you're talking about executables and other MMAP'ed objects the filesystem IS the swap (when apache needs to be swapped out the kernel just deletes it from memory and reloads from disk - unless the executable pages were modified - not sure how dynamic linking is handled in linux, and if that needs to modify code pages). Unless of course your swap is encrypted or something it should be faster than the FS... > > 50mb in swap - and everything is slow. So slow as if every bit is fetched by a > mule caravan. And it does not matter if it is a swap partition or a swap > file. It is slow. > I haven't seen this behavior - I routinely have maybe 500MB swapped out. The difference is that most of this is probably tmpfs data that isn't touched until tmpreaper comes around and deletes it. The critical factor is probably RSS - if you have a zombie process that uses 1GB of RAM and which sleeps for 3 days at a time (with NO activity) then if you swap it out there is probably no impact. On the other hand, if you have 50 processes all running with 2%CPU each and they each have a 100MB RSS and you have 1GB of RAM your system will come to a complete halt. Even if all combined they only need 1.1GB of RAM you'll probably still come to a halt since they'll be constantly churning that 100MB of swap. If 100MB worth of processes sleep suddenly the whole system will wake up. Basically, there is no fix for lots of RUNNING processes other than more RAM (or not running everything at once). But lots of idle processes do just fine with swap. And not having a swap partition doesn't stop swapping. Any time you mmap a file you have virtual memory - no getting around it. And that data will get swapped in and out as needed. And even if none of your software uses mmap the kernel does every time it loads an image. It greatly improves performance (unused code never gets loaded). If I'm wrong on any of this kindly point it out, but this is my understanding of how linux swapping works. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFF9whqG4/rWKZmVWkRAr0EAJ440jI6WPQO3dR9ldn6lYVYTb2WkwCfRgFT sPEuMMbiyY4k1MtFn2nHEWI= =dBn2 -----END PGP SIGNATURE----- [-- Attachment #2: S/MIME Cryptographic Signature --] [-- Type: application/x-pkcs7-signature, Size: 3875 bytes --] ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-amd64] Is swap need when there is 4g of ram? 2007-03-13 14:32 ` Hemmann, Volker Armin 2007-03-13 20:24 ` Richard Freeman @ 2007-03-14 14:19 ` Jack Lloyd 2007-03-14 17:01 ` Hemmann, Volker Armin 1 sibling, 1 reply; 19+ messages in thread From: Jack Lloyd @ 2007-03-14 14:19 UTC (permalink / raw To: gentoo-amd64 On Tue, Mar 13, 2007 at 03:32:45PM +0100, Hemmann, Volker Armin wrote: > 50mb in swap - and everything is slow. So slow as if every bit is fetched by a > mule caravan. And it does not matter if it is a swap partition or a swap > file. It is slow. > > But there is an easy way to get the box back to normal speed: swapoff -a && > swapon -a ... Perhaps better to tweak the VM so it is not as swap-happy using /proc/sys/vm/swappiness. See http://kerneltrap.org/node/1044 -- gentoo-amd64@gentoo.org mailing list ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-amd64] Is swap need when there is 4g of ram? 2007-03-14 14:19 ` Jack Lloyd @ 2007-03-14 17:01 ` Hemmann, Volker Armin 2007-03-14 17:26 ` Bernhard Auzinger 0 siblings, 1 reply; 19+ messages in thread From: Hemmann, Volker Armin @ 2007-03-14 17:01 UTC (permalink / raw To: gentoo-amd64 On Mittwoch, 14. März 2007, Jack Lloyd wrote: > On Tue, Mar 13, 2007 at 03:32:45PM +0100, Hemmann, Volker Armin wrote: > > 50mb in swap - and everything is slow. So slow as if every bit is fetched > > by a mule caravan. And it does not matter if it is a swap partition or a > > swap file. It is slow. > > > > But there is an easy way to get the box back to normal speed: swapoff -a > > && swapon -a ... > > Perhaps better to tweak the VM so it is not as swap-happy using > /proc/sys/vm/swappiness. See http://kerneltrap.org/node/1044 swappiness does not help, if swap is really needed (like when compiling kdepim). The 'stupid' thing is, as soon as swap is used, it stays that way, no matter how many hundred mb of ram are free. -- gentoo-amd64@gentoo.org mailing list ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-amd64] Is swap need when there is 4g of ram? 2007-03-14 17:01 ` Hemmann, Volker Armin @ 2007-03-14 17:26 ` Bernhard Auzinger 2007-03-14 19:03 ` Hemmann, Volker Armin 0 siblings, 1 reply; 19+ messages in thread From: Bernhard Auzinger @ 2007-03-14 17:26 UTC (permalink / raw To: gentoo-amd64 > swappiness does not help, if swap is really needed (like when compiling > kdepim). I did not reconize yet that kdepim is that hungry at compile time :). > The 'stupid' thing is, as soon as swap is used, it stays that way, > no matter how many hundred mb of ram are free. The reason for that behaviour is, that in my opinion it would be nonsense to delete things from the swap when there is enough swap space free. But I think you can be sure that if there is enough ram free that the things will also be in the ram again. Things are kept (duplicated) in the swap space if there is enough swap because it's faster when it's necessary to swap out the same things again, I think. That's just a theory. I don't know for sure if I'm right. rgds Bernhar -- gentoo-amd64@gentoo.org mailing list ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-amd64] Is swap need when there is 4g of ram? 2007-03-14 17:26 ` Bernhard Auzinger @ 2007-03-14 19:03 ` Hemmann, Volker Armin 2007-03-14 21:21 ` Bernhard Auzinger 2007-03-15 10:00 ` [gentoo-amd64] " Duncan 0 siblings, 2 replies; 19+ messages in thread From: Hemmann, Volker Armin @ 2007-03-14 19:03 UTC (permalink / raw To: gentoo-amd64 On Mittwoch, 14. März 2007, Bernhard Auzinger wrote: > > swappiness does not help, if swap is really needed (like when compiling > > kdepim). > > I did not reconize yet that kdepim is that hungry at compile time :). > j2 for MAKEOPTS and +kdeenablefinal and after some time each one of the makejobs want 900mb ram. There are two libs where that happens, makes kdepim the slowest-to-compile packet for me. Wesnoth is also an offender. Some versions want 500mb+ at some point when compiling. -- gentoo-amd64@gentoo.org mailing list ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-amd64] Is swap need when there is 4g of ram? 2007-03-14 19:03 ` Hemmann, Volker Armin @ 2007-03-14 21:21 ` Bernhard Auzinger 2007-03-15 10:00 ` [gentoo-amd64] " Duncan 1 sibling, 0 replies; 19+ messages in thread From: Bernhard Auzinger @ 2007-03-14 21:21 UTC (permalink / raw To: gentoo-amd64 > j2 for MAKEOPTS and +kdeenablefinal and after some time each one of the > makejobs want 900mb ram. There are two libs where that happens, makes > kdepim the slowest-to-compile packet for me. Wesnoth is also an offender. > Some versions want 500mb+ at some point when compiling. That's pretty much. About 3 years ago I watched a similar behaviour on PyQt. At that time I had just 512MB of ram (and a 1.2GHz pentium3) and that tiny package drove me crazy because the memory requested by gcc when compiling PyQt was more than 512MB and the compile process did not only happen on data stored in the ram but also on data stored in the swap space. It was awful. My system was not usable for more than an hour. It was so busy swapping as I never saw a system swapping before. I remember that after a upgrade to 1G ram the PyQt package took less than five minutes. I decided to trace the memory usage when compiling PyQt and I recognized that it was less than a minute requesting so much memory. That was the first time I was convinced that swapping can end very very bad. rgds Bernhard -- gentoo-amd64@gentoo.org mailing list ^ permalink raw reply [flat|nested] 19+ messages in thread
* [gentoo-amd64] Re: Is swap need when there is 4g of ram? 2007-03-14 19:03 ` Hemmann, Volker Armin 2007-03-14 21:21 ` Bernhard Auzinger @ 2007-03-15 10:00 ` Duncan 1 sibling, 0 replies; 19+ messages in thread From: Duncan @ 2007-03-15 10:00 UTC (permalink / raw To: gentoo-amd64 "Hemmann, Volker Armin" <volker.armin.hemmann@tu-clausthal.de> posted 200703142003.11766.volker.armin.hemmann@tu-clausthal.de, excerpted below, on Wed, 14 Mar 2007 20:03:11 +0100: > j2 for MAKEOPTS and +kdeenablefinal and after some time each one of the > makejobs want 900mb ram. There are two libs where that happens, makes > kdepim the slowest-to-compile packet for me. Wesnoth is also an > offender. Some versions want 500mb+ at some point when compiling. In general c++/g++ is FAR more memory and CPU intensive than gcc compiling C. I look at it this way (non-technical explanation), the OOP functionality of C++ is a great productivity enhancement for programmers, making them more effective. However, the tradeoff is that it makes the compiler work harder doing all the stuff automatically that the programmer didn't do manually. For those of us using split KDE packages rather than the monolithic versions, kmail is the particular part of kdepim that requires the huge resources. With USE=kdeenablefinal (which is designed for file distribution level compilation, and turns on a bunch of compile resource expensive optimizations to make run-time performance as good as possible), on AMD64 at least, one specific compile job in that package requires over a gig of memory at one particular point. Anybody who has only a gig of memory WILL be in swap at that point, there's no way around it except to USE=-kdeenablefinal for that package, setting it in package.use or whatever. It'd be interesting to be enough of a programmer to figure out exactly what's requiring all that memory, but it's beyond my rather limited capacities in that area, so... -- Duncan - List replies preferred. No HTML msgs. "Every nonfree program has a lord, a master -- and if you use the program, he is your master." Richard Stallman -- gentoo-amd64@gentoo.org mailing list ^ permalink raw reply [flat|nested] 19+ messages in thread
* [gentoo-amd64] Re: Is swap need when there is 4g of ram? 2007-03-13 9:09 [gentoo-amd64] Is swap need when there is 4g of ram? P.V.Anthony 2007-03-13 9:56 ` Hemmann, Volker Armin @ 2007-03-13 14:30 ` Duncan 2007-03-18 3:42 ` P.V.Anthony 2007-03-13 18:04 ` [gentoo-amd64] " Peter Humphrey 2 siblings, 1 reply; 19+ messages in thread From: Duncan @ 2007-03-13 14:30 UTC (permalink / raw To: gentoo-amd64 "P.V.Anthony" <pvantony@singnet.com.sg> posted 45F66A32.1050004@singnet.com.sg, excerpted below, on Tue, 13 Mar 2007 17:09:06 +0800: > Is swap really needed when there is a 4g of ram? As VAH says, depends. I ran without swap with a gig of RAM for some time. That was generally enough for me. Only one time did I actually run out of memory, when I tried to scan a larger than really necessary image at too high a resolution and color depth. However... There are several reasons to run swap. It's likely that at least one of the following will apply. Less so with current kernels, but it wasn't that long ago (certainly well into the 2.6 series, maybe 2.6.12-ish?) that the kernel had no direct way to switch memory between different "memory zones". There could be plenty of memory, but memory of a specific type, say in the PCI 32-bit direct DMA zone (up to 4 gig, but note that due to the memory hole for it at just below 4 gig, 4 gigs of actual memory will map a quarter to a half a gig above the 4 gig memory barrier) could be tight, with no way to rearrange things that could otherwise be moved elsewhere into other memory zones, without using the "backing store" of swap. Put simply, swap gave the kernel more flexibility in how it managed memory, a flexibility that could be useful at times. Eventually, the kernel hackers implemented a way to transfer memory between zones without resorting to backing store (aka swap), so this no longer applies to modern kernels per se, but the general idea of flexibility continues to. Disabling swap entirely kills the kernel's ability to memory-map a file on disk without reading it into physical memory. This actually doesn't use the swap space, just maps the file where it is into memory without actually reading it into memory. There are times when this is more efficient than actually reading the whole thing into memory, and disabling swap (as in turning off the virtual memory option before compiling the kernel, I believe it can still do it if the option is on but no swap space is actually allocated, tho I'm not positive on that) kills this flexibility. OK, so those don't apply to a modern kernel in many operational circumstances. It's nice to have the flexibility, but... Still, there are other reasons to keep swap around. There's a balance between cache and swap. With swap turned off, data and memory for all running apps, including those that don't actually run very much (say print services on a system where something's actually printed perhaps once or twice a week on average), /must/ be maintained in real memory. What's used for such applications cannot be used for caching files so they don't actually have to be read off disk once they are read the first time. If you generally never top off memory and cache to the point where the system is throwing away cache to keep memory, and with 4 gig, you may not, unless you use some of the tricks below, it doesn't matter so much, but the minute you start throwing away cache to keep stuff like a seldom used CUPS print system in memory, because you have swap disabled, you begin to slow down your next read of the cached data you just threw away. BTW, with swap enabled, there is a knob you can tweak that sets the kernel's balance between keeping apps vs. keeping cache in memory, when one or the other needs dumped in ordered to make room for something just coming in. /proc/sys/vm/swappiness defaults to a generally reasonable 60, IIRC, but can be set to anything between 0 and 100. Here, I'm running a reasonably fast RAID system with 4-way striped swap, and a 4- spindle RAID-6, effectively making it two-way striped. Since swap is four-way striped while my main system is only two-way striped, swap should be faster than reading stuff back in from the RAID-6, so as part of my boot sequence I "echo 100 > /proc/sys/vm/swappiness". That means the kernel will /always/ prefer keeping cache, dumping the least used applications to swap where necessary. Conversely, people who run a single hard drive with both swap and most of their filesystem on it, who run an slocate updatedb cron job over night and come back to a really sluggish system the next morning because the kernel has swapped all their still loaded firefox tabs and the like out in favor of caching what amounts to the single-shot updatedb data, may wish to set swappiness lower than the default 60, say 20, or even 0, at which point the system would always favor the apps and always dump cache, when it came to that point. However, the BIG payoff of lots of memory (4 gig or so being a sweet spot for this), particularly for Gentoo systems or anyone else doing a lot of "temp" work, compiling or the like, is to setup a large (several gig) tmpfs and do all your compiling and stuff there, only copying the completed files over to the main non-volatile filesystem. On Gentoo, it's particularly easy to use a tmpfs for compiling and the like, by simply setting the appropriate PORTAGE_TMPDIR and similar variables in make.conf. With "only" four gig of memory, however, and with certain packages requiring sizable work areas (OOo is said to require on the order of 4-5 gigs!), trying this without swap risks severe memory shortage situations. I have a full 8 gig memory and a 5 gig tmpfs /tmp (with portage pointed to it) here, and even with 8 gigs memory, if I try emerging several things in parallel, it's not unusual to see active swap as a result. On a four gig system, I'd DEFINITELY want swap backup if I had PORTAGE_TMPDIR and friends pointed at tmpfs (which I might then try at 3 GB max size, tho obviously that wouldn't work if I tried to compile OOo or something nearly as big). It's worth repeating. A tmpfs based PORTAGE_TMPDIR is probably the single best use for 4 gig of memory on a normal Gentoo system, but it's not something I'd recommend anyone try without swap. Therefore, I'd recommend a tmpfs be setup for portage to use, and that swap remain enabled for the system to use in the event it needs it when portage is compiling something big. To try to setup that tmpfs for portage to use /without/ swap enabled... might be OK on an 8 gig system tho I'm not going to try it myself, but is certainly risking trouble and instability on a 4 gig system. Finally, note that the in-kernel hibernate (aka suspend to disk) functionality requires a dedicated swap partition of sufficient size. Suspend to disk is /finally/ working here, and it's a nice feature to have. However, it /does/ require swap space to suspend into. (Note that the swap partition doesn't have to be the full size of RAM. Each of my swap stripes is only 4 gig, making 16 gig of swap available, but suspend will only use one stripe, so 4 gig. I have 8 gig memory but only a 4 gig swap stripe partition to suspend to, but it works fine.) If you are using a non-vanilla kernel with the Suspend2 patch, or something similar, this may or may not apply, as I think it's possible for it to use a non- swap suspend file. However, with the mainline in-kernel suspend, at least last I read, it requires swap. That's actually why I re-enabled swap here, tho it was quite some time before I could actually get suspend to disk to actually work as advertised. I kept swap enabled and would try it every few kernel versions, and it finally started working! So in summary, four reasons to keep swap enabled: 1) Old kernels needed it for memory zone management. (N/A for a decently modern kernel, say 2.6.16 or newer.) 2) Memory mapped file flexibility. 3) tmpfs based PORTAGE_TMPDIR and friends is generally a MUCH more efficient use of several gigs of memory than turning off swap, but until you have I'd say 6 gigs memory minimum, you'll want to keep swap enabled if you do it. 4) Suspend to disk, aka hibernate, uses swap. #3 and possibly #4 are the important ones. OTOH, disabling swap entirely, by turning off that config option in kernel setup before compiling it, DOES significantly simplify kernel code and memory management. This was in fact the reason I had it off back when I had only a gig of memory. I had system stability issues due to unstable memory hardware (cheap memory) at the time, and I figured the less complicated kernel memory management was, the more stable the system was likely to be. I don't know if it made much of a difference, but it definitely wasn't LESS stable. (The memory zone issues did apply back then, but my hardware simply wasn't stable enough for that to be much of an issue.) -- Duncan - List replies preferred. No HTML msgs. "Every nonfree program has a lord, a master -- and if you use the program, he is your master." Richard Stallman -- gentoo-amd64@gentoo.org mailing list ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-amd64] Re: Is swap need when there is 4g of ram? 2007-03-13 14:30 ` Duncan @ 2007-03-18 3:42 ` P.V.Anthony 0 siblings, 0 replies; 19+ messages in thread From: P.V.Anthony @ 2007-03-18 3:42 UTC (permalink / raw To: gentoo-amd64 On this day, 13-March-2007 10:30 PM, Duncan wrote: > So in summary, four reasons to keep swap enabled: > > 1) Old kernels needed it for memory zone management. (N/A for a decently > modern kernel, say 2.6.16 or newer.) > > 2) Memory mapped file flexibility. > > 3) tmpfs based PORTAGE_TMPDIR and friends is generally a MUCH more > efficient use of several gigs of memory than turning off swap, but until > you have I'd say 6 gigs memory minimum, you'll want to keep swap enabled > if you do it. > > 4) Suspend to disk, aka hibernate, uses swap. > > #3 and possibly #4 are the important ones. > > OTOH, disabling swap entirely, by turning off that config option in > kernel setup before compiling it, DOES significantly simplify kernel code > and memory management. This was in fact the reason I had it off back > when I had only a gig of memory. I had system stability issues due to > unstable memory hardware (cheap memory) at the time, and I figured the > less complicated kernel memory management was, the more stable the system > was likely to be. I don't know if it made much of a difference, but it > definitely wasn't LESS stable. (The memory zone issues did apply back > then, but my hardware simply wasn't stable enough for that to be much of > an issue.) Thank you to all for advising on the swap issue. The information is very useful and has helped me to make a decision. I am happy. For the record, I am going with swap file of 4g. Once again thank you all for the advice. P.V.Anthony -- gentoo-amd64@gentoo.org mailing list ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [gentoo-amd64] Is swap need when there is 4g of ram? 2007-03-13 9:09 [gentoo-amd64] Is swap need when there is 4g of ram? P.V.Anthony 2007-03-13 9:56 ` Hemmann, Volker Armin 2007-03-13 14:30 ` Duncan @ 2007-03-13 18:04 ` Peter Humphrey 2 siblings, 0 replies; 19+ messages in thread From: Peter Humphrey @ 2007-03-13 18:04 UTC (permalink / raw To: gentoo-amd64 On Tuesday 13 March 2007 09:09:06 P.V.Anthony wrote: > > Is swap really needed when there is a 4g of ram? Yes. That assumes that you will be compiling lots of large programs such as mozilla-firefox and Open Office. Let me tell you about my case: I have 4 GB RAM and 2 x Opteron 246 CPUs, and I have three 2GB swap parttions: one each on 2 x IDE and 1 x SATA disks. I've told portage to use the /tmp directory for its work, and /tmp is mounted on tmpfs with a size of 6.5 GB. If /tmp occupancy outgrows the physical RAM, the kernel swaps part of it out to disk and carries on. Magic! I run top in an X terminal when I want to monitor swap use. It shows me that the only time the swap gets used is when I'm compiling one of those large packages. Open Office, in particular, uses up to 5.7 GB of temporary space on my box, which is why I've set the /tmp limit to 6.5 GB. It may actually use more, but that's the most I've observed. This box also spends nearly all its cycles on BOINC projects (http://boinc.berkeley.edu/), which not only ramps up the temp and noise, but of course uses a fair amount of space. All the same, I still don't see any use of swap except on those prodigious compiling jobs. So, if you don't intend to compile large packages, you probably don't need swap; if you do, you do. HTH. -- Rgds Peter Humphrey Linux Counter 5290, Aug 93 -- gentoo-amd64@gentoo.org mailing list ^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2007-03-18 3:44 UTC | newest] Thread overview: 19+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-03-13 9:09 [gentoo-amd64] Is swap need when there is 4g of ram? P.V.Anthony 2007-03-13 9:56 ` Hemmann, Volker Armin 2007-03-13 12:46 ` Joaquim Quinteiro Uchoa 2007-03-13 13:39 ` Hemmann, Volker Armin 2007-03-13 14:28 ` Joaquim Quinteiro Uchoa 2007-03-13 14:35 ` Hemmann, Volker Armin 2007-03-14 23:00 ` Paul de Vrieze 2007-03-13 14:11 ` dustin 2007-03-13 14:32 ` Hemmann, Volker Armin 2007-03-13 20:24 ` Richard Freeman 2007-03-14 14:19 ` Jack Lloyd 2007-03-14 17:01 ` Hemmann, Volker Armin 2007-03-14 17:26 ` Bernhard Auzinger 2007-03-14 19:03 ` Hemmann, Volker Armin 2007-03-14 21:21 ` Bernhard Auzinger 2007-03-15 10:00 ` [gentoo-amd64] " Duncan 2007-03-13 14:30 ` Duncan 2007-03-18 3:42 ` P.V.Anthony 2007-03-13 18:04 ` [gentoo-amd64] " Peter Humphrey
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox