5 ms·
I've been reading these stories for ten years. About 8 years ago I started taking them seriously and stopped using swap. Turns out not having swap works much be
by lmm 10y ago
I've been reading these stories for ten years. About 8 years ago I started taking them seriously and stopped using swap. Turns out not having swap works much better. I'm amazed how slowly the consensus seems to be moving though.
- njharman 10y agoSystems are used for vastly different purposes. With different memory usages and expected operation. There can be no consensus because there is no one answer.
- tossaway1 10y ago> I've been reading these stories for ten years. About 8 years ago I started taking them seriously and stopped using swap. Not sure what you're referring to here. This story doesn't recommend eliminating swap...
- tyingq 10y ago"Systems without swap can make sense and are supported by Red Hat - just be sure the behaviour of such a system under memory pressure is what you want" So, it doesn't exclusively recommend it, but it concedes that there are use cases where it makes sense.
- problems 10y agoYeah. I've had issues with this on some systems. On Windows without swap when you hit a remotely low on RAM point, things start going really poorly for some reason - random latency. So with 16 GB of RAM even I can't disable swap on Windows without some really strange performance characteristics, I run SSDs so I really wanted it off and I just stuffed more RAM in my box - with 32 GB it isn't a problem. On Linux however, you can pretty much turn it off and everything will run smooth until you're actually out and then you lag badly briefly, Linux's oom-killer does its thing and all is good again within the span of a few seconds.
- jandrese 10y agoI've noticed the same thing, Windows just becomes bizarrely cranky if you disable swap entirely. My solution was to instead leave it on, but limit it to just a couple of megabytes. That seems to avoid the VM subsystem freakouts thus far.
- speeder 10y agoSadly, trying to investigate this is quite hard, since people are outright hostile to questions about it. If you ASK about swapping on windows, you get people telling you that "Microsoft engineers are smart, don't disable swap and go <insert expletive here>" even if you asked something that is NOT about disabling swap. So, I had this gamer laptop, i7, nVidia GPU, 8GB of RAM (when most machines had 2 or 4), but some stupidly slow 5k RPM HDD made for power saving and locked "noiseless mode", thus very slow seek too (ie: it moves the heads slowly to avoid making noise and for aerodynamic reasons). I noticed that ever after I just booted up, RAM usage would jump to 6gb and the HDD would trash endlessy and make the machine unusable... after some research I found some interesting posts by MS employees about it: Windows can "preemptively" use swap, it will write on swap things it thinks you might need to swap out. Sounds good on paper. Also, Windows has several caching systems, that will write to "RAM" random crap. One day that was particularly bad, I noticed that when I booted, Windows would immediately attempt to copy to RAM a gigantic binary file that was the sound files of a game I played a lot recently, this caused trashing due to reading the file, then, it would attempt to load other programs it had to, then page out immediately, and enter some crazy loop of trashing the I/O forever... Every time I opened the task manager and looked at the graphs, disk I/O would be constantly maxed out at 100%... Disabling the VM made the laptop behave better (despite all the bugs Windows have when you disable VM). But what I really wanted, was to change how the VM works... I wanted to keep the VM, and the caching, but change settings, for example I would set it to NOT page out anything at all unless RAM was used more than 80%, and also to never "cache" stuff unless HDD was actually idle and a good amount of RAM free. But sadly, this can't be done it seems, I got no useful answer on stackexchange sites when I asked this (But got a couple personal messages and e-mails full of expletives in many places where I asked about it, for some reason people get personally offended when the subject is virtual memory).
- pizzetta 10y agoAren't there legacy applications which expect swap where otherwise with modern applications swap isn't necessary? Or, at least that is my current (mis)-understanding...
- rogerbinns 10y agoTwo examples of why I have swap: * On a laptop to hibernate, which results in zero power consumption vs suspend which will drain the battery in a day or so * I use tmpfs for /tmp and using swap as the backing is far more performant than regular filesystems
- lmm 10y ago> * I use tmpfs for /tmp and using swap as the backing is far more performant than regular filesystems This seems absurd. You're running an in-memory filesystem backed by memory-on-disk? You weren't comparing to a journalled filesystem or something like that?
- rogerbinns 10y agoSince I do use journalled filesystems for my real data, your comment implies I should create yet another partition for /tmp using a filesystem that optimises performance over durability/integrity, eg without journalling. I consider files in /tmp to be temporary, and do not expect them to survive a reboot. (Actually I prefer they don't - less administration and housekeeping.) They also have random lifetimes ranging from fractions of a second to several days. And random sizes from zero length to gigabytes (eg making an ISO image). With tmpfs RAM is used which provides the best performance since the filesystem is trivial. Memory pressure will cause swap to be used as needed. Files not accessed will end up in the swap and taking no RAM. By far the fastest I/O is the I/O you don't have to perform.
- lmm 10y ago> Since I do use journalled filesystems for my real data, your comment implies I should create yet another partition for /tmp using a filesystem that optimises performance over durability/integrity, eg without journalling. If you're using a swap partition just for the sake of /tmp then it's the same difference, no?
- rogerbinns 10y ago
- jcrites 10y agoWe reached this same conclusion for our servers generally. The problem with swap is that it's unpredictable. It's better most of the time to have a system that's predictable. However much RAM is available to the system, you can deal with that, by making an appropriate choice of hardware type, or by scaling up, tuning software, etc. It's harder to deal with performance problems related to use of swap in my experience, since it's nondeterministic what will be swapped.
- contingencies 10y agoDitto, and over that period memory has become even cheaper. I sort of wonder if we'll see a 100% RAM, large memory laptop soon that boots from an SD-card or in a cryptographically secure fashion over 4G wireless networks, aggressively disables RAM for power saving and suspends well.