That's why I don't use swap.
For example: you have a background program that you're not using and in the foreground you're crunching data from disk. In this scenario the most efficient use of your memory is to swap the background program out and pull the disk data into RAM.
Then comes the challenge of deciding what processes/data to free or page, whether that's flagged by the system as it's running or at coding/compile time. And that seems similar to the issue of picking a swap strategy for a distro/OS, which will depend on the user's demands or system, setting a good default and exposing how to change the configuration to a better match if needed.
You can tweak this, it is indeed a local-system configuration thing that a Linux user should know and think about - and maybe - if your distro has such a thing as a policy about it - this ought to be considered as well.
For example, I use Ubuntu Studio, precisely because it is generally well set up, swap-wise, to absolutely not interfere with audio performance (note: this DAW has been rock solid for decades) .. but every distro has its own 'medium ground' to consider when setting this.
The thesis/antithesis for/against swap is un-useful. Swap is a knob, not a switch.
Shuffling out 8GB with a spinning hard drive could take a full minute…
That said, I agree with you. I’d rather not use swap unless absolutely necessary and I don’t want the latter to happen either…
Plus, I don’t want my storage in the “critical path” of memory accesses, even if rare.
If you need an application to always be responsive, start it with the swappable flag turned off, i.e. something like this:
$ systemd-run --user --scope \
-p MemorySwapMax=0 \
-- /path/to/my/program arg1 arg2
Anyway, this is a distro-originated knob which every user must tweak for their use-case.These are separate problems, though. You can clean a page by updating its backing store without purging it from memory; and purging a clean page doesn’t require a write. It’s definitely reasonable to take advantage of idle IO resources to clean dirty pages, but pages should only be purged (clean pages first, usually) when there’s an immediate need for them for something else.