wblock@ said:
Swap isn't used unless it's needed, anyway. Actually, that should be qualified: on FreeBSD, swap isn't used unless it's needed. Other operating systems--which will not be named except to say that it's Windows--swap before they're out of RAM. I've asked why, but never really had a satisfactory answer. Best I can come up with is that UnnamedOS moves things into swap so that RAM will be free and available. So instead of being slow when out of RAM, it's slow all the time.
Anyway, FreeBSD only uses swap when RAM is full.
I can actually see the logic behind swapping idle processes to disk pro-actively.
Say you have a 1 gigabyte system with 500 megabytes available. Of your 500 megabytes (roughly) of consumed memory, 120 megabytes is "idle".
If you pro-actively swap that to disk, an alloc for say, 550 megabytes of RAM will be instant as you won't need to start paging to disk before the alloc can occur - you simply mark the idle process memory as free as it is on disk already anyway. If the process wakes up, you just mark the pages it modifies as dirty and page them when it goes idle again.
Also, by pro-actively paging idle processes to disk, you could potentially use the RAM they were consuming for disk cache for another process which is hitting the disk hard.
I'm pretty sure this is how OS X on Lion and later seems to page to disk, from my observations. They've obviously played with the thresholds a bit, as Mavericks is way snappier than Lion was on release (I suspect Lion was tested internally only on SSD), but the theory seems to hold true when compared to what I see happening on my OS X box.
Waiting until you run out of RAM before paging means that typically, your performance goes to poo (due to THEN needing to start paging out) right when your machine is working hard (which would tend to be when you want it to be doing work, rather than paging excessively). Paging out idle processes pro-actively, well in advance could help reduce that.
In other words what I'm saying is this: aggressively swapping out could potentially improve performance due to more RAM being available for disk cache, for processes which are doing heavy IO.