4 ms·
Turning off swap should give you this result. Then instead of trying to move stuff to swap which causes the system to be slow or unresponsive, the kernel will j
by askl 3y ago
Turning off swap should give you this result.
Then instead of trying to move stuff to swap which causes the system to be slow or unresponsive, the kernel will just start killing processes.
- dale_glass 3y agoNot guaranteed, there's more than swap that the kernel can use, such as mmap. Disabling swap is a very coarse optimization. The ultimate problem is performance. If you have 16GB RAM + 10GB of stuff sitting completely idle, that works perfectly fine. If you have 16GB RAM + no swap + a process that requires 15GB RAM and uses all of that constantly, it's going to be painful, as the kernel tries to compensate by squeezing memory out of anywhere it can, over and over.
- rcxdude 3y agoNo, sadly. This doesn't happen in my experience. The main reason seems to be that executable code is memory mapped from disk anyway. So in a low-memory scenario, that gets evicted, causing the same kind of thrashing but worse because it's essentially forced to be focused on really active areas instead of the least active. The end result is instead of a slow bogging down like you get with swap enabled, you get a sudden freeze which may eventually resolve itself but during which the system is almost completely unresponsive. In general if you are running without swap I would strongly recommend you do use something like earlyoom.
- mnw21cam 3y agoAgreed - most people don't realise, but even if you don't have any swap, all your executable code is effectively treated exactly the same way as swap (except it's read-only and needed more often). I'd love a setting on Linux to tell it to treat executable pages memory-mapped from disc as Really Important and never evict them. It'd have to come with a suitable warning that if you set this then you get exactly what you deserve, but TBH it probably is what most people actually think is happening already and want.
- askl 3y agoHeh, thanks for explaining this. Maybe my general aversion towards swap wasn't fully based on facts.