3 ms·
I'm sorry, but not a single reason was presented in favour of swap when you're 100% confident that you will not max out your RAM. Swap = completely useless slow
by Kenji 9y ago
I'm sorry, but not a single reason was presented in favour of swap when you're 100% confident that you will not max out your RAM. Swap = completely useless slowdown if you have total control over your system.
Better use ulimit to prevent processes with e.g. memory leaks from causing havoc.
- __david__ 9y agoThey presented one reason: the system will swap out more or less unused memory and give that much more space for disk cache, etc. Now, I'm not sure I find this a particularly compelling reason. I suppose it depends on how much RAM you have available for cache vs how much unused junk gets swapped out. If you've got 5G of unused RAM and 300M extra of stale allocations that get swapped out, then it's probably not going to impact your system in any measurable way. I personally like a quick OOM, myself, rather than a machine slowing down to a crawl for multiple minutes while swap gets exhausted.
- subway 9y agoRAM freed by swapping some infrequently accessed memory out to disk becomes available for cache use. If you have total control of your system, you know when you can safely allow data to be paged, and when you need to lock memory to physical ram.
- ChrisSD 9y agoCan you ever be 100% confident?
- notyourday 9y agoYes. ulimit and cgroups do wonders.
- warrenm 9y agoYou can 100% be confident (except in a few very unusual use cases) that swap is important, yes. https://news.ycombinator.com/item?id=15952447 https://news.ycombinator.com/item?id=15952447
- efaref 9y agoThe most compelling reason to enable at least some swap space is that the Linux kernel's memory handling algorithms can't cope with there being no swap. If you have no swap, then you will encounter stalls and OOMs even if you don't actually run out of memory. Adding even a tiny amount of swap prevents this from happening.
- albertzeyer 9y agoThis sounds as if it is a serious issue and should be fixed. Is there a bug report about it?
- lolc 9y agoThis is due to memory overcommit, it's a performance feature. You can turn it off.
- kevin_nisbet 9y agoInteresting, I sort of remember an interaction with NUMA as well. I don't believe this is a bug, just a miss-understanding of the way the underlying system works. From what I remember when swapiness is 0, there are lots of reports of processes that use more than a single NUMA node worth of memory getting killed by the OOM killer, even with plenty of free RAM available. I unfortunately don't remember the details, but this prevented the memory from being able to be allocated to the additional node. I've heard of this mostly with mysql, where it's common to have a big server with lots of RAM, but a single large process that uses most of the system RAM. The way we got around this, was by setting the process to allocate interleaved among the NUMA nodes. I'll have to dig into the overcommit.
- warrenm 9y agoIt's not a serious issue at all. It's intentional.
- bechampion 9y agoi agree with this , lack of swap makes oom too aggressive . , question what's worst no app (and react to OOM) or app swapping
- warrenm 9y agoWant reasoning? Here's a whole huge list: https://news.ycombinator.com/item?id=15952447 https://news.ycombinator.com/item?id=15952447 When it is the case in the overwhelming majority of cases that you should use swap, you should just use it.