2 ms·
The ideal would be to go into swap without becoming unresponsive, so that the user can quit a program of their choice to free memory. If you really want to make
by chowells 1mo ago
The ideal would be to go into swap without becoming unresponsive, so that the user can quit a program of their choice to free memory. If you really want to make an issue out of it, do something like pre-X macOS, where it would provide a warning when you are getting close to running out of memory, so that a user might have the chance to do something before the current process starts getting swapped out.
- hnlmorg 1mo ago> The ideal would be to go into swap without becoming unresponsive, so that the user can quit a program of their choice to free memory. Linux already does this. The issue is when your swap is full too, or you’ve exhausted your RAM at such a rapid pace that the disk IO cannot keep up with the read and writes to swap. I’ve seen Windows choke under the same conditions too. > do something like pre-X macOS, where it would provide a warning when you are getting close to running out of memory, so that a user might have the chance to do something before the current process starts getting swapped out. This is where the desktop and the kernel being entirely separate organisations (not even projects, but literal organisations) makes things a touch harder. And those DEs aren’t even Linux specific either. So any tooling would have to portable (which, in fairness, should be possible with POSIX in this particular scenario). I think KDE does provide tools here for gracefully handling memory constraints. But that’s just one desktop environment of many.
- LtdJorge 1mo ago>> do something like pre-X macOS, where it would provide a warning when you are getting close to running out of memory And I've run out of memory while compiling packages (I'm looking at you, composable-kernel) on Gentoo. It's not like it can notify me and I close things in the milliseconds it takes for a few more GCC processes to spawn and allocate and fault all the remaining memory.
- eru 1mo ago> [...] or you’ve exhausted your RAM at such a rapid pace that the disk IO cannot keep up with the read and writes to swap. I don't know what that means. When your system is in such extreme memory pressure, it comes to a crawl, exactly because your memory use can't outpace your IO. There's no 'cannot keep up' state.
- LtdJorge 1mo agoSwap is extremely slow. And if running it on a high-end NVMe, you better hope you don't swap often.
- eru 1mo agoMacOS uses swap all the time. Btw, there's (at least) two sides to swap: (1) While there's plenty of headroom, you might still want to swap out 'cold' memory, so you can keep more files cached in RAM. (2) When you are (nearly) out of memory, you need to evict to swap so that you don't run out-of-memory. Swap mostly helps you, when you have plenty of cold memory that are pretty much never accessed again. Or when you have applications that you switch, but that you don't use concurrently. When your active working set is bigger than your RAM, then, yes, swap is slow.