I’m writing a high-performance server application (on Linux) and I’m trying to get a fast critical path. I’m concerned about memory paging and having memory swapped to disk (latency on order of milliseconds) during my operations.
My question is if I have a lot of memory on the server (say 16GB) and my memory utilization stays at around 6-10GB and I know there are no other processes on the same box. Can I be guaranteed not to have page misses after the application is started up and warm?
This is not guaranteed. Linux’s default behavior is to sometimes use RAM to cache files, which can improve performance for some workflows. This means that sometimes memory pages will be swapped out even when the memory isn’t all used.
You can use mlock/mlockall to lock the process’s pages in memory. See
man 2 mlockfor more information.