Linux – tmpfs and vm.swappiness

linuxmemoryswaptmpfsvirtual-memory

I have started tuning a bit Linux VM performance on my system (yes. I know that vm.swappiness=0 will kill kittens but I found 30-40 as much better for me as it improved my latency – probably at cost of throughput). I would like to ask how the tmpfs is counted (is it cache or program) for purpose of swapping and vm.swappiness.

To give higher level I need a folder which:

  • Usually is empty but usage might increase to up to 8x my main memory size
  • Do not need to be preserved about reboots
  • Is low priority as far as I/O is concerned (i.e. programs using it might wait) but it would be nice if it was fast

Currently I'm using a normal FS. I heard (not tested) about problems with large tmpfs pushing the data on swap. Since I assume that tests were done with default vm.swappiness=60 and tmpfs is simply occupying only cache the decreased vm.swappiness would make it easier swappable during memory pressure. Am I correct?

Best Answer

tmpfs is implemented as cache pages, so a low value for vm.swappiness will make tmpfs files more likely to be swapped out, since the system will favor stealing cache pages over application pages.