6 ms·
The post alleges that this this is due to "aggressive swap". I suspect that the MacOS developers at Apple know their target hardware, so I'm wondering (if this
by neilv 6y ago
The post alleges that this this is due to "aggressive swap". I suspect that the MacOS developers at Apple know their target hardware, so I'm wondering (if this is the situation) whether the developers realized it, but the product was shipped anyway.
FWIW, even as a developer who mostly stays out of the kernel, swap has long been on my mind for Linux laptops (e.g., keeping pre-SSD spinning-rust hard drives sleeping), and I pretty much always disable swap, even on desktops. Part of the rationale is, if I can't fit all the processes in (now) several gigabytes of RAM, something probably needs an OOM-euthanizing.
- eru 6y agoSwap is most useful, when you (almost) never look at the swapped out data again. That might sound stupid, but it occurs often enough in practice: eg code or data structures that were only used when starting off the program in question. An optimally coded program wouldn't benefit from this. But real world programs often do.
- mytherin 6y agoI wouldn't link the usefulness of swap to the quality of programs. It has a lot to do with user behavior. If a user opens 100 tabs in a web browser but never looks at most of them, swapping unused ones to disk if they don't fit in RAM anymore is a very useful behavior (considering the alternative is killing the entire program). You could argue an optimally coded program should do this themselves, however, that is not so easy when multiple programs are running concurrently and fighting for RAM. On an 8GB machine, how much RAM should your web browser use? The answer is "it depends". If there are no other programs running, it can use all 8GB. If you are running an IDE, a chat client and a compiler in the background, it should probably be using less. The individual programs don't have enough information to make this judgement call - and making very conservative estimates will lead to much more swapping than actually required. The operating system is in charge of allocating memory for all those programs and can effectively make the judgement of what should be swapped out or not.
- xxs 6y agoIf you hit the swap, there is no disk cache. Which is problematic on its right own.
- eru 6y agoHuh? Swapping out unused stuff leaves more space for the disk cache.
- xxs 6y agodisk cache is just 'free memory', when swap is used there is no free memory. Pretty much any OS (linux, windows, macos) use the unallocated memory for disk cache. Disk swap also takes RAM as page descriptors.
- eru 6y ago> [...] when swap is used there is no free memory. Well, that's not true. In Linux you can have pages swapped out to disk and physical memory used for disk cache at the same time.
- IshKebab 6y agoI always disabled swap on Linux (back when I was using HDDs) because it was completely useless anyway. As soon as you ran out of RAM and it started using swap the entire system would grind to a halt and you'd basically have no choice but to restart it, killing all processes rather than just random ones. There doesn't seem to have been any effort by Linux developers to fix that (e.g. provide a kernel level GUI to let you pick which processes to kill when out of RAM).
- ynik 6y agoUnfortunately disabling swap doesn't really fix the problem you're talking about -- Linux will just grind to a halt trashing the page cache instead.
- vetinari 6y ago> There doesn't seem to have been any effort by Linux developers to fix that (e.g. provide a kernel level GUI to let you pick which processes to kill when out of RAM). There is no and will be no GUI for that, especially considering that many linux devices do not have any. However, that does not mean there is no effort to improve the situation. The main player here is, surprisingly, Facebook. Their effort is going to be integrated into systemd in the form of systemd-oomd and Fedora 34 is going to ship it enabled out of the box (see https://fedoraproject.org/wiki/Changes/EnableSystemdOomd https://fedoraproject.org/wiki/Changes/EnableSystemdOomd).
- IshKebab 6y ago> especially considering that many linux devices do not have any Why not? Many Linux devices don't have keyboards but it supports those perfectly well. I hadn't heard of systemd-oomd, sounds interesting!
- rollcat 6y agoYou may want to reconsider whether you want swap disabled: http://jdebp.uk./FGA/dont-throw-those-paging-files-away.html http://jdebp.uk./FGA/dont-throw-those-paging-files-away.html