Live data from Hacker News

In defence of swap: common misconceptions

chrisdown.name

101–110 of 151 posts

Re: In defence of swap: common misconceptions

#101

Earlier quoted context omitted.

And even then; they provision an absurd amount of it. I just did a fresh Ubuntu install. On a machine with 32 gigs ram, it creates a 32 gig swap partition by default!

They probably reason that you want your system to be able to hibernate, plus storage is cheap. I have 8GB of swap for the 8GB in my laptop, for that reason. On my desktop with 16GB, the w 2GB of swap it has is sometimes too little, and everything grinds to a halt.

32GB of SSD isn't that cheap!

Re: In defence of swap: common misconceptions

#102
post #88

In my experience, a misbehaving linux system that's out of RAM and has swap to spare will be unusably slow. The process of switching to a tty, logging in, and killing whatever the offending process is can easily take a good 15 minutes. Xorg will just freeze. Oh, and hopefully you know what process it is, else good luck running `top`. Until this is fixed, I'll just keep running my systems with very small amounts of sw…

I actually did this on a old laptop, setup 200mb of swap for 4gb of ram. And it caused huge problems for me, would run out of swap while having plenty of free memory and then go cripplingly slow.

Set the swappiness lower.

Re: In defence of swap: common misconceptions

#103

How long before desktop OSs manage memory like mobile ones, automatically shutting down background apps that aren't being used, so that the system remains responsive no matter what? Or, worst case, if two tasks that need 8GB each are running on a machine with 8GB memory, kill one, let the other finish, and restart the first one. Or, less ambitious, freeze one, swap it out to disk, let the other finish, and only then…

> How long before desktop OSs manage memory like mobile ones, automatically shutting down background apps

Once desktop systems and applications support required APIs to handle saving state before being shut down.

Re: In defence of swap: common misconceptions

#104
post #39

Earlier quoted context omitted.

There have been times when I have needed to do something which requires more memory than is physically available on the machine. Without swap, those tasks would have been literally impossible to do without upgrading the machine. With swap, it just takes a little longer - but still much shorter than it would take to order more RAM sticks. One of those times was on a 512MB RAM VPS, where I needed to compile something -…

Well, they wouldn't have been literally impossible. Anything that can be done with swap can be done by writing the data to disk and then reading it back. That's all swap is doing.

Ok, you are technically correct; I _could_ have changed GCC to cache stuff to disk instead of keeping everything in RAM (which would probably have been a big refactor), but I think we both know that's not really practical.

Re: In defence of swap: common misconceptions

#105
post #98
post #82

I'd be more convinced by the argument that swap shouldn't be thought of as slow RAM if the author addressed the fact that it's generally known as 'virtual memory'—and it has been since at least System 370, so it's not simply a later misconception: http://pages.cs.wisc.edu/~stjones/proj/vm_reading/ibmrd2505M... . Instead the article just omits the term 'virtual memory' completely, and pretty conspicuously. I also thin…

That is not the argument. The article actually says, four times over, that it should not be thought of as emergency memory . It's not emergency memory; it's ordinary memory that should see use as part of an everyday memory hierarchy. And if you are going to question the terminology, the elephant in the room that you have missed is calling paging swapping. (-:

Despite the repeated use of the word 'emergency' this is not quite obvious. For example in

> many people just see it as a kind of “slow extra memory” for use in emergencies

the scare quotes are around 'slow extra memory' not 'emergencies'. Now granted in the last bullet point of the conclusion it affirms that VM is a source of slow memory, but earlier it uses 'memory' where it's referring specifically to RAM, for example

> Without swap: Anonymous pages are locked into memory as they have nowhere to go.

Really the main reason my original comment was rubbsih is that I took the article far too much as a general discussion of swap when, as it said, it's largely about how much swap to enable on a given Linux system running some already-determined software.

Re: In defence of swap: common misconceptions

#106

Earlier quoted context omitted.

I don't see any option to separate that in the settings page, is it hidden behind a flag somewhere?

In about:config search for browser.cache.memory.capacity and browser.cache.disk.capacity.They are in kilobytes. To enable or disable any of those caches use browser.cache.disk.enable and browser.cache.memory.enable.

Thanks!

Re: In defence of swap: common misconceptions

#107

In my experience, a misbehaving linux system that's out of RAM and has swap to spare will be unusably slow. The process of switching to a tty, logging in, and killing whatever the offending process is can easily take a good 15 minutes. Xorg will just freeze. Oh, and hopefully you know what process it is, else good luck running `top`. Until this is fixed, I'll just keep running my systems with very small amounts of sw…

In 2005 I was able to run Linux on 512MB RAM _without_ swap (on purpose - every day) without issues. Today it will bark at me on 8GB of RAM for not having swap enabled.

Re: In defence of swap: common misconceptions

#108

Very few people on this thread read and understood the article. The point isn't working with data sets larger than RAM. The point is making better use of the RAM you do have by taking pages you'll almost never touch and spilling them to disk so that there's more room in RAM for pages you will touch. Banning swap is like making self-storage companies illegal and forcing everyone to hold all possessions in their homes.…

> Very few people on this thread read and understood the article. Hmm. I read the article and I think I understood it. However, in my experience, you run out of RAM if and only if your working set is too big. In my experience, all involved find it desirable to reduce the size of the working set as quickly as possible. Your experience seems to differ. > The point isn't working with data sets larger than RAM. The point…

> (1) The kernel can predict which pages the user will "almost never touch."

> I disagree with (1). [...] The kernel does not have sufficiently detailed knowledge of the process's purpose or access patterns.

You're in for quite a surprise, particularly on desktop. I have a number of processes with some pages swapped out, and I see no impact on interacting with the said processes. Firefox, gDesklets, a volume changer, and several instances of rxvt are among them.

> (2) Mispredicting which pages will be "almost never touched" is of relatively low cost.

> I also disagree with (2). The consequences of getting these predictions wrong seem to be very bad.

Only in the case of repeated mispredictions, which only happens if you really have low RAM and are on a good way to invoke OOM killer anyway. With (1) being quite accurate (mainly because swapping out unused pages is not that aggressive), (2) magically becomes true as well.

Re: In defence of swap: common misconceptions

#109
post #69

Earlier quoted context omitted.

> you can also add more RAM (it's just expensive) Or just impossible Many laptops still have remarkably low maximum-RAM limits. The ones I have here ( Dell SME & corporate types ) are 4GB and 8GB. I live in constant fear of the solid-blue disk-access lamp. And when I boot-up after a swap-thrash I am scolded for an unclean shutdown :(

You have not given an actual example of "impossible." A computer that can hold more RAM than 4-8 GB is possible to obtain, at some cost. You may object to the cost ("expensive"), but it is not impossible.

Well, considering that current Intel laptop chipsets support only 16g of RAM, this is pretty much a hard limit. Yes, you can switch to desktop hardware, but that is limited to usually heavier devices which run shorter on battery. So there are some very practical limits on increasing the RAM.

Re: In defence of swap: common misconceptions

#110
post #99

Earlier quoted context omitted.

"Very few people on this thread read and understood the article." I started to read the article, and then thought, "I know this, who doesn't know this?" and stopped. "The point is making better use of the RAM you do have by taking pages you'll almost never touch and spilling them to disk so that there's more room in RAM for pages you will touch." Exactly. Who with any technical experience in this day and age doesn't…

> Exactly. Who with any technical experience in this day and age doesn't understand that You're on a site infamous for the comment "I switch to Node when I want to be close to the metal".

Is this a joke or was there actually such a comment? If so, can you link it?

To someone like me, who usually lives somewhere between C++ and shader code, it sounds a bit too strange to be true.

Post reply on HN