News for hackers. Stuff that matters.
Re:In defence of swap: common misconceptions by gok on Monday June 08, 2020 @10:36PM (#23463083)
> On SSDs, swapping out anonymous pages and reclaiming file pages are essentially equivalent in terms of performance/latency

…but very much not equivalent in terms of how much you are wearing out your SSD.

> Swap can make a system slower to OOM kill

This is almost always actually a bad thing. Turning on swap means your system goes from randomly killing processes to suddenly running 100x slower than it used to and then randomly killing processes.

Re:In defence of swap: common misconceptions by pmoriarty on Monday June 08, 2020 @11:29PM (#23463389)
Yeah, but in the meantime you might actually notice that your system is slowing down, investigate and possibly fix the issue or intelligently kill the right process.
Re:In defence of swap: common misconceptions by mrob on Tuesday June 09, 2020 @03:09AM (#23464451)
In practice, everything slows to an unusable crawl, and you hit the reset button because it's the fastest way of regaining control. IMO, earlyoom or similar is essential for general desktop use where memory load is unpredictable. Better to lose one process than lose all of them.

"The oom-killer generally has a bad reputation among Linux users. This may be part of the reason Linux invokes it only when it has absolutely no other choice. It will swap out the desktop environment, drop the whole page cache and empty every buffer before it will ultimately kill a process. At least that's what I think that it will do. I have yet to be patient enough to wait for it, sitting in front of an unresponsive system."

https://github.com/rfjakob/earlyoom

Re:In defence of swap: common misconceptions by kalleboo on Tuesday June 09, 2020 @07:39AM (#23465689)
I guess Linux is different from macOS since I just had this situation last week. I wrote a quick app to generate a graphic and let it run in the background, noticed my machine was feeling a bit sluggish (but still totally usable for web browsing etc) and noticed my app had a memory leak and was using 100 GB of RAM and climbing on a 32 GB system. I could easily quit the app using the regular GUI.

NVMe SSDs are fantastic.

Re:In defence of swap: common misconceptions by gok on Tuesday June 09, 2020 @11:28AM (#23467474)
macOS has also has Jetsam (like the Linux OOM killer but much more aggressive) and swap-to-compression, so you're not as often swapping to disk as you'd think.
Re:In defence of swap: common misconceptions by kalleboo on Tuesday June 09, 2020 @11:43AM (#23467607)
My app was leaking uncompressed 12 MP photo buffers and the swap file was over 70 GB, so in this case it was definitely swapping to hell
Re:In defence of swap: common misconceptions by steerablesafe on Tuesday June 09, 2020 @03:51AM (#23464653)
> In practice, everything slows to an unusable crawl

This is my experience as well. Maybe this could be mitigated with cgroup v2 by setting some processes to never swap so the user doesn't lose interaction with the system.

Re:In defence of swap: common misconceptions by tsimionescu on Tuesday June 09, 2020 @03:54AM (#23464665)
Unfortunately, that can happen to a much worse extent if swap is turned off. Linux will swap out all file-backed pages before invoking the OOM Killer, and since all user-space code is sitting in memory mapped pages, it will start swapping out code. And if you think waiting for disk to do a memory read is slow, imagine what waiting for disk to see what is the next available instruction can do to the system.
Re:In defence of swap: common misconceptions by luckylion on Tuesday June 09, 2020 @03:05AM (#23464423)
Is there a trick to reserve a percentage of actual RAM to be used for investigations and fixes? Because unless you already have a working shell open on the machine etc, are you going to wait 10 minutes for ssh to spawn a child, then 10 minutes for the shell to load and give it another 5 minutes for your ps to show?
Re:In defence of swap: common misconceptions by Arnt on Tuesday June 09, 2020 @03:53AM (#23464660)
BTDT, a lot of times. In the meantime I notice the system is slowing down, but I can't kill the guilty process because the system is too slow to ssh in. The ssh client times out while the ssh server is trying to obtain the pages it needs.

Swap is what turns the deficient OOM killer from a minor to a major problem.

Re:In defence of swap: common misconceptions by sophiebits on Tuesday June 09, 2020 @02:02AM (#23464123)
I think the author clearly acknowledges that is a bad thing but argues that other advantages outweigh it.