I've set swappiness on my DB server to zero, but during a large sort operation the swap space used grew even as the cache was still using a lot of memory, and then cache grew but swap was left alone. This makes no sense to me. Here's free -m
as of now:
total used free shared buffers cached
Mem: 16000 15979 20 0 24 10520
-/+ buffers/cache: 5434 10565
Swap: 6111 5478 633
This is happening in the middle of a large sort in PostgreSQL. The issue is that the swapped out memory will probably be called upon as soon as the sort is over (it's a big UPDATE
on a table I put into tmpfs), resulting in a huge slowdown as it will be random access.
How much space are you using in your tmpfs?
Bear in mind that tmpfs is backed by cache, and shows up in that statistic. So, the normal advice of "ignore cached and use the +/- line" doesn't necessarily apply.
In fact, tmpfs is swappable, so it's very possible that that's what's getting swapped out as your real memory pressure increases.