> reading file-backed pages from files is slower than swapping from compressed ram
Which, in turn, is slower than not swapping at all. To avoid swapping unless absolutely needed, you set swappiness to 0. On the opposite side, to swap as soon as the kernel sees an opportunity, you tune swappiness to 200.
"There is a common misconception that swappiness affects the memory threshold or prevents using swap space, but it only affects the preference for freeing up file pages over swap."
As I understand it, Linux does not preemptively evict idle anonymous or file-backed pages, only as a response to memory pressure.
Thank you for the pointer. Apparently I was among those who misinterpreted swappiness!
The name suggests it is the willingness to use the swapping mechanism, while it is the willingness to use the swap partition (or file). The variables anon_prio and file_prio that the kernel uses internally are much clearer!
To be honest, I've always felt like the kernel distinguishing anonymous and file-backed memory this was is a ugly kludge and that everything would be simpler if we though of anonymous memory as being backed by an anonymous file.
Which, in turn, is slower than not swapping at all. To avoid swapping unless absolutely needed, you set swappiness to 0. On the opposite side, to swap as soon as the kernel sees an opportunity, you tune swappiness to 200.