[luv-main] Can you have too much swap?

Hi All, I'm about to set up a new linux box, but not all of the bits have arrived yet. I currently only have 512MB of RAM in the machine, but ultimately, it will have at least 2GB, possibly 4. If I let the installer do it's own thing with HDD partitioning, it will set up a swap size of 2 x RAM. But that's not what I want. 2 x the current amount of RAM will be inadequate once I install more. So, if I set up 8GB of swap, expecting that I'll eventually have 4GB of RAM, is having too much swap going to be a problem in the meantime? Is there a downside to having a large amount of swap? Leigh.

Leigh Sharpe <leigh.sharpe@gmail.com> wrote:
So, if I set up 8GB of swap, expecting that I'll eventually have 4GB of RAM, is having too much swap going to be a problem in the meantime?
I don't think so.
Is there a downside to having a large amount of swap?
No, but of course your system will slow down substantially if you use a lot of virtual memory and it has to rely on swap space heavily. An alternative would be to configure swap files rather than swap partitions, allowing you to adjust the size as you wish.

On Mon, Nov 21, 2011 at 2:33 PM, Leigh Sharpe <leigh.sharpe@gmail.com>wrote:
Hi All, I'm about to set up a new linux box, but not all of the bits have arrived yet. I currently only have 512MB of RAM in the machine, but ultimately, it will have at least 2GB, possibly 4. If I let the installer do it's own thing with HDD partitioning, it will set up a swap size of 2 x RAM. But that's not what I want. 2 x the current amount of RAM will be inadequate once I install more. So, if I set up 8GB of swap, expecting that I'll eventually have 4GB of RAM, is having too much swap going to be a problem in the meantime? Is there a downside to having a large amount of swap?
Personally I think swap = ram x 2 is an old rule that doesn't make sense any more. Unless you plan to suspend, then you really don't need any more than 1gb of swap. Just enough for the kernel to use for paging things in and out. Quite frankly if you find yourself needing 1gb of swap, or even 500mb of swap then you need to re-evaluate your hardware. cheers, / Brett

On 20/11/11 19:33, Leigh Sharpe wrote:
I'm about to set up a new linux box, but not all of the bits have arrived yet. I currently only have 512MB of RAM in the machine, but ultimately, it will have at least 2GB, possibly 4.
er, RAM is now $10/GB. I see no reason for using anything less then 8 or 16. Two of my three laptops have 8GB (both T410's, it's the most they'll do), the last is my occasional mac which only has 2GB (can take 4, but it's due for replacement). My desktops one has 12, one 24 (both are triple channel Intel machines). My personal servers are all at 8GB as they're older machines (except for a HP MicroServer used as a NAS which I've yet to upgrade from 1GB).
If I let the installer do it's own thing with HDD partitioning, it will set up a swap size of 2 x RAM. But that's not what I want. 2 x the current amount of RAM will be inadequate once I install more. So, if I set up 8GB of swap, expecting that I'll eventually have 4GB of RAM, is having too much swap going to be a problem in the meantime? Is there a downside to having a large amount of swap?
For the last few years I've gone to using a flat 2GB of swap. My theory is that hard drives are *so* slow (at 100MB/sec that's 20sec to fill it) that you'd much rather services be killed by the OOM killer then wait minutes for a response (when you're fairly likely just to need to kill it anyway). This is for laptops, desktops and servers (and several hundred of them at my last job were built this way).

On Sun, 20 Nov 2011, Julien Goodwin wrote:
On 20/11/11 19:33, Leigh Sharpe wrote:
I'm about to set up a new linux box, but not all of the bits have arrived yet. I currently only have 512MB of RAM in the machine, but ultimately, it will have at least 2GB, possibly 4.
er, RAM is now $10/GB. I see no reason for using anything less then 8 or 16.
Um, mobos that can only fit 4GB? Laptops that are new can barely take many more. Still. Stupid market only wanting Windows 32 bit. The upgrading treadmill that crappy developers force upon us because they can't be bothered to write efficient programs anymore are a great cause of the wastage that modern society suffers from. I keep buying machines that are maxed out with memory at purchase time, but a few years down the track are suffering with a workload that doesn't seem like it should be all that different. Meanwhile, I can't just upgrade ram, because the mobo is already maxed out. I have to upgrade the whole computer despite the rest of it still working well (partly because I've been able to incrementally improve bits of it as bits improved). 'course, the linux VMM sucks mightily. I would have upgraded to kFreeBsd by now if I didn't want to run a proprietry web browser that isn't built for kFreeBsd+debian. Actually, that webbrowser is the primary reason why I run deeply into swap. But it copes better than firefox even after it repeatedly finally allegedly solves that old memory leak problem once and for all.
Two of my three laptops have 8GB (both T410's, it's the most they'll do), the last is my occasional mac which only has 2GB (can take 4, but it's due for replacement). My desktops one has 12, one 24 (both are triple channel Intel machines). My personal servers are all at 8GB as they're older machines (except for a HP MicroServer used as a NAS which I've yet to upgrade from 1GB).
I don't want a desktop because I want my electricity usage to be below a constant 60watts. My 2 laptops and a small pile of external disks manages this according to my UPS. -- Tim Connors

On 20/11/11 20:31, Tim Connors wrote:
On Sun, 20 Nov 2011, Julien Goodwin wrote:
On 20/11/11 19:33, Leigh Sharpe wrote:
I'm about to set up a new linux box, but not all of the bits have arrived yet. I currently only have 512MB of RAM in the machine, but ultimately, it will have at least 2GB, possibly 4.
er, RAM is now $10/GB. I see no reason for using anything less then 8 or 16.
Um, mobos that can only fit 4GB?
Either they're single stick mobo's for compact systems, or you should upgrade.
Laptops that are new can barely take many more. Still. Stupid market only wanting Windows 32 bit.
My (now four year) old T61 could take 8GB (except it overheated, 6GB was reliable).
The upgrading treadmill that crappy developers force upon us because they can't be bothered to write efficient programs anymore are a great cause of the wastage that modern society suffers from. I keep buying machines that are maxed out with memory at purchase time, but a few years down the track are suffering with a workload that doesn't seem like it should be all that different. Meanwhile, I can't just upgrade ram, because the mobo is already maxed out. I have to upgrade the whole computer despite the rest of it still working well (partly because I've been able to incrementally improve bits of it as bits improved).
I will say that some of this is new algorithms that are only practical with large amounts of RAM, some of the simulation stuff we use in Google NetOps is like that.
'course, the linux VMM sucks mightily. I would have upgraded to kFreeBsd by now if I didn't want to run a proprietry web browser that isn't built for kFreeBsd+debian. Actually, that webbrowser is the primary reason why I run deeply into swap. But it copes better than firefox even after it repeatedly finally allegedly solves that old memory leak problem once and for all.
Opera doesn't do that, and as it's the only proprietry browser I'm aware of on Linux I
Two of my three laptops have 8GB (both T410's, it's the most they'll do), the last is my occasional mac which only has 2GB (can take 4, but it's due for replacement). My desktops one has 12, one 24 (both are triple channel Intel machines). My personal servers are all at 8GB as they're older machines (except for a HP MicroServer used as a NAS which I've yet to upgrade from 1GB).
I don't want a desktop because I want my electricity usage to be below a constant 60watts. My 2 laptops and a small pile of external disks manages this according to my UPS.
I only run a desktop at work because I'm forced to, and my one at home is for games. Haven't done proper power measurements on my servers though, but I do everything possible to keep the power usage down, as that keeps the heat down.

On Mon, 21 Nov 2011, Julien Goodwin <luv-lists@studio442.com.au> wrote:
er, RAM is now $10/GB. I see no reason for using anything less then 8 or 16.
Um, mobos that can only fit 4GB?
Either they're single stick mobo's for compact systems, or you should upgrade.
The biggest problem that I have observed is motherboards with Intel chipsets that can only address 4G of RAM and reserve ~700M of that for PCIe thus leaving only ~3.3G of addressable RAM. My latest system has 4 DIMM slots and only 3.3G usable.
Laptops that are new can barely take many more. Still. Stupid market only wanting Windows 32 bit.
My (now four year) old T61 could take 8GB (except it overheated, 6GB was reliable).
A large part of my motivation for moving to a desktop was to avoid the heat problems in my Thinkpad which had 5G and could have been expanded to 8G. 3.3G is enouugh as I use a Xen server on my network (compared to KVM on localhost when using the Thinkpad) and I avoid having too many Chromium tabs open at once.
The upgrading treadmill that crappy developers force upon us because they can't be bothered to write efficient programs anymore are a great cause of the wastage that modern society suffers from. I keep buying machines that are maxed out with memory at purchase time, but a few years down the track are suffering with a workload that doesn't seem like it should be all that different. Meanwhile, I can't just upgrade ram, because the mobo is already maxed out. I have to upgrade the whole computer despite the rest of it still working well (partly because I've been able to incrementally improve bits of it as bits improved).
I will say that some of this is new algorithms that are only practical with large amounts of RAM, some of the simulation stuff we use in Google NetOps is like that.
Sure, but then there's the fact that web browsing worked quite nicely on a system with 16M of RAM in 1995 and a significant part of my web browsing hasn't changed much since then.
I don't want a desktop because I want my electricity usage to be below a constant 60watts. My 2 laptops and a small pile of external disks manages this according to my UPS.
I only run a desktop at work because I'm forced to, and my one at home is for games. Haven't done proper power measurements on my servers though, but I do everything possible to keep the power usage down, as that keeps the heat down.
One thing to note is that you have to measure these things. There is overlap between laptop and desktop power use. You can get a 64bit desktop system running on about 60W including monitor while the high-end laptops apparently exceed 100W - I've heard accounts of airlines providing only 120W of electricity to a passenger and having the circuit-breaker trip when a laptop is plugged in. -- My Main Blog http://etbe.coker.com.au/ My Documents Blog http://doc.coker.com.au/

On Mon, Nov 21, 2011 at 4:09 PM, Russell Coker <russell@coker.com.au> wrote:
On Mon, 21 Nov 2011, Julien Goodwin <luv-lists@studio442.com.au> wrote:
I will say that some of this is new algorithms that are only practical with large amounts of RAM, some of the simulation stuff we use in Google NetOps is like that.
Sure, but then there's the fact that web browsing worked quite nicely on a system with 16M of RAM in 1995 and a significant part of my web browsing hasn't changed much since then.
Really? I can't speak for how you browse the web today, or in 1995, but my habits are vastly changed. There were no tabbed browsers back then, so I remember a very serialised process of loading a page, reading it, and then following a link. Doing one thing at a time. There was no webmail, so I didn't have gmail open, that was done via telnet and pine. There were no twitter, facebook, youtube, google music, web forums, wikis, and the like. Those use a lot of ram. Now, I have, on this computer, 4 Chromium windows open, each one with between 5 and 15 tabs open. I switch between tabs as I need, and open many tabs in the background then process them, rather than doing things in a serial way. This has a cost in memory, clearly, but that's why I have machines with 8gb of ram in them. I think if you're honest with yourself you'll admit that the way you browsed the web in 1995 has absolutely no similarities with how you do it now. cheers, / Brett

Hello, Russell Coker:
high-end laptops apparently exceed 100W - I've heard accounts of airlines providing only 120W of electricity to a passenger and having the circuit- breaker trip when a laptop is plugged in.
Odds are that would be charging current, though, not power consumption. Jiri -- Jiri Baum <jiri@baum.com.au> http://www.baum.com.au/sabik

On Wed, 23 Nov 2011, Jiri Baum <jiri@baum.com.au> wrote:
Russell Coker:
high-end laptops apparently exceed 100W - I've heard accounts of airlines providing only 120W of electricity to a passenger and having the circuit- breaker trip when a laptop is plugged in.
Odds are that would be charging current, though, not power consumption.
http://www.tomshardware.com/reviews/technical-foundations-diy-solar-powered- pc,1693.html If a laptop when charging uses >120W then it probably uses >60W when active which makes it in the same range as desktop systems. Admittedly the above PC design from Tom's Hardware is quite a bit different from what most of us have on our desktops. But I think it demonstrates that a desktop PC designed for low power use can equal high end laptops for power use while beating them for performance. -- My Main Blog http://etbe.coker.com.au/ My Documents Blog http://doc.coker.com.au/

On Mon, 21 Nov 2011, Julien Goodwin <luv-lists@studio442.com.au> wrote:
If I let the installer do it's own thing with HDD partitioning, it will set up a swap size of 2 x RAM. But that's not what I want. 2 x the current amount of RAM will be inadequate once I install more. So, if I set up 8GB of swap, expecting that I'll eventually have 4GB of RAM, is having too much swap going to be a problem in the meantime? Is there a downside to having a large amount of swap?
For the last few years I've gone to using a flat 2GB of swap. My theory is that hard drives are *so* slow (at 100MB/sec that's 20sec to fill it) that you'd much rather services be killed by the OOM killer then wait minutes for a response (when you're fairly likely just to need to kill it anyway). This is for laptops, desktops and servers (and several hundred of them at my last job were built this way).
http://etbe.coker.com.au/2007/09/28/swap-space/ The above URL is for the most popular blog post I have ever written. In it I describe the reasons for the 2*RAM rule and why it doesn't apply nowadays. I also speculated about whether I would ever use more than 2G of swap, since then I have found cases where large amounts of swap are useful. The case for 2+G of swap is when you have lots of browser tabs open at once and not doing anything. For a desktop system I have found no other usage case where such large amounts of swap do any good. For a server I have NEVER found a case where large amounts of swap were ever any good, but I concede the fact that there are surely some daemons out there which allocate large amounts of RAM and do little with it. -- My Main Blog http://etbe.coker.com.au/ My Documents Blog http://doc.coker.com.au/

Leigh Sharpe wrote:
Hi All, I'm about to set up a new linux box, but not all of the bits have arrived yet. I currently only have 512MB of RAM in the machine, but ultimately, it will have at least 2GB, possibly 4. If I let the installer do it's own thing with HDD partitioning, it will set up a swap size of 2 x RAM. But that's not what I want. 2 x the current amount of RAM will be inadequate once I install more.
AIUI "twice the RAM" is advice for pre-Linux unices that did something particularly dumb -- maybe stop-and-copy paging or something. IMO, the Right Thing is to 1. no swap. If you need 2GB of memory, buy 2GB of RAM; 2. no RAM overcommit. This means malloc returns an error rather than handing the problem over to the OOM killer. 3. fix any programs that make inappropriately large, up-front mallocs; likewise those that do not handle errors from malloc appropriately (even if "appropriately" means asserting malloc success). Obviously this advice is inappropriate in some contexts - varnish obviously springs to mind.

On Mon, 21 Nov 2011, "Trent W. Buck" <trentbuck@gmail.com> wrote:
AIUI "twice the RAM" is advice for pre-Linux unices that did something particularly dumb -- maybe stop-and-copy paging or something.
It's for Unix systems that allocated a page in swap for every page in virtual memory.
IMO, the Right Thing is to
1. no swap. If you need 2GB of memory, buy 2GB of RAM;
That's almost never the best advice. There are always pages that never get accessed after initialisation and can be paged out. I even use swap on my EeePC 701...
2. no RAM overcommit. This means malloc returns an error rather than handing the problem over to the OOM killer.
Given that RAM is cheap and disk space is usually plentiful that's a viable option nowadays. Of course you will probably encounter programs that malloc() vastly more memory than they need which happen to work well on the majority of Linux systems.
3. fix any programs that make inappropriately large, up-front mallocs; likewise those that do not handle errors from malloc appropriately (even if "appropriately" means asserting malloc success).
Obviously this advice is inappropriate in some contexts - varnish obviously springs to mind.
Also most people on this list aren't capable of following step 3. Even I would be hesitant to do that, I already have enough bugs to fix. -- My Main Blog http://etbe.coker.com.au/ My Documents Blog http://doc.coker.com.au/

On 21/11/11 20:54, Trent W. Buck wrote:
1. no swap. If you need 2GB of memory, buy 2GB of RAM;
There's a relatively recent article (Feb 2011) in Linux Journal about swap and Linux here: http://www.linuxjournal.com/article/10678 cheers, Chris -- Chris Samuel : http://www.csamuel.org/ : Melbourne, VIC

At 10:04 AM 11/22/2011, Chris Samuel wrote:
On 21/11/11 20:54, Trent W. Buck wrote:
1. no swap. If you need 2GB of memory, buy 2GB of RAM;
There's a relatively recent article (Feb 2011) in Linux Journal about swap and Linux here:
Quite an informative article. 73 de VK3JED / VK3IRL http://vkradio.com
participants (10)
-
Brett Pemberton
-
Chris Samuel
-
Jason White
-
Jiri Baum
-
Julien Goodwin
-
Leigh Sharpe
-
Russell Coker
-
Tim Connors
-
Tony Langdon
-
Trent W. Buck