4 ms·
Imho: if you 'need' swap, you're running the wrong software. If an OS+apps' working set exceeds RAM, performance will slow to a crawl in any case. Best (and o
by RetroTechie 3y ago
Imho: if you 'need' swap, you're running the wrong software.
If an OS+apps' working set exceeds RAM, performance will slow to a crawl in any case.
Best (and only?) argument I've seen for having swap, is that in a gradually building out-of-memory situation (say, a memory leak), swap buys the admin more time to respond / diagnose the problem.
That is a valid reason. Use swap where it applies.
But for eg. desktop systems: pointless. Some app eating all the RAM? Crash right now, please! Then it's usually obvious which app was the culprit. As opposed to slowing everything to a crawl slowly over time & leaving the user to wonder what's going on.
- throwawaaarrgh 3y agoI'm sorry, but you don't understand swap. It's useful to retain all kinds of memory in different scenarios, like cache, or windows that haven't been accessed in a while. It can free up fast memory, reducing contention and speeding up the system. And you can control snappiness to decide what and when things get swapped. Swap is also used by the system's hibernate function to store a copy of RAM to disk. If you have 64GB of RAM and no combination of your apps, cache, etc will ever approach that, then probably nothing will ever swap. But for more limited systems or when running apps with higher memory pressure, swap does increase system performance.
- donkeybeer 3y agoI don't know how representative firefox hardware survey would be of the general population, but https://data.firefox.com/dashboard/hardware https://data.firefox.com/dashboard/hardware 4 and 8 gb ram seem still most common.
- AnotherGoodName 3y agoEven in the 64gb case you're still losing out since the OS will use free memory as file cache. No swap just means you think everything ever allocated should always stay in ram. In pretty much every system there's going to be a few GB that were allocated but never really needed. I'd rather that not be true but since it is I'd like that stuff paged out to give the os more file cache.
- nine_k 3y agoSwapping to an HDD used to be slow. Swapping to an NVMe device is incomparably faster. Swapping out the data which take longer to compute that to read from the swap when needed does make things faster. But for the swap to work efficiently, you still need to have enough RAM to run the things you want to run right now. The slowing to a crawl occurs when the running apps try to touch pages all over the place, requiring very frequent swapping in/out. Then yes, it's time to terminate something and free up some space.
- duped 3y agoModern MacOS relies heavily on swap. It's not uncommon to see 2-3GB of swap in use at a time, even for a while after memory becomes available. > Some app eating all the RAM? crash right now, please? It's ambiguous which is using "all the RAM." If you have game in one window and browser in another, and you start seeing high memory pressure, which should crash? Or if you're building software and you've fanned out to dozens of processes building dependencies concurrently but all using very little memory independently, which ones should be OOM-killed? Alternatively you can see processes that haven't been woken or taken focus in awhile and page their memory out to swap to release main memory for applications that need it, and avoid crashing or losing data.
- ptero 3y agoThere are plenty of one-off tasks that can cause a short, transient memory need. Killing anything due to this is generally a bad idea. As an example: I run a small Hetzner cloud instance (for about $4.50/month) for quick prototyping when I am away from home. It has a nowadays-considered-wimpy 2GB of RAM. It also exposes a Jupyter server that I (or friends) can use for quick experiments from anywhere in the world. Some time ago I added torch and torchvision modules for a quick size comparison on a couple of models (just number of trainable parameters) and "pip install torch" got OOM-killed before I realized that I have zero swap and added it (and could have deleted it after the install). This is not a common example, but a general observation that while using swap in the production servers, running one thing in a highly predictable fashion (uhm, sure) might mask the problem you want to expose, swap is extremely useful for general-purpose computers that occasionally run things that cause memory use spikes and are not particularly sensitive on whether they take a few milliseconds or a few seconds. My 2c.
- theragra 3y agoI don't think are are right. I used GIS software with SSD, and it handle huge files with SSD as ram alternative (swapped). Maybe it is better to do this in a different way, but this definitely works.
- project2501a 3y agoin HPC systems, especially in bioinformatics, astrodynamics or fluid dynamics, if you don't have swap, you are asking for trouble, mostly cuz the code has been written by graduates of each field who can't program
- xorcist 3y ago> If an OS+apps' working set exceeds RAM, performance will slow to a crawl in any case That sounds like a misunderstanding how memory is allocated and this may be the root of it. There are many instances where this would be completely expected. The most trivial perhaps being an application that mmap() a file much larger than memory. That is a perfectly valid thing to do.
- deleted 3y ago[deleted]
- dotnet00 3y ago"You're running the wrong software" is exactly the kind of attitude that's frustrating about a lot of current developers. Instead of compatibility you'd rather just act like users are complete idiots.