by dschuetz · 4y ago · 0 comments
It's the use cases that make a difference.
1. Makes claims about performance 2. Provides no benchmarks
The only concrete answer to "why have swap if I have enough RAM" is "well, if you run out of RAM..."
The only time swap isn’t just delaying (and growing) the inevitable shitshow is when, for some reason:
1) some program is consuming some significant amount of Ram, but doesn’t need to run for awhile, and it’s somehow faster/easier to let it swap to disk than shutting it down and restarting it while you do something else that consumes Ram.
2) something you’re running has some amount of bloat or leak that you know will never get exercised, but also never will grow larger than your swap file and take your system out entirely.
Both of those situations are not only rare, but easy to misjudge and end up wedging your system.
And then compilation eventually finishes and the allocated memory is released on process termination.
Linux with swap available can swap out never used pages (say a part of library that never gets called) and use freed memory to cache disk IO. We see that on every server that has enough data to fill the remaining RAM with page cache. But you only need like a gig of swap to take advantage of it.
The OS will page in files that are being accessed regularly. Without a swap file you don't stop the OS swapping between memory and disk, that'd be pathological since disk access is that much slower.
Instead what not having a swapfile really means is that you are telling the OS "anything allocated ever on the system is more important than disk cache".