3

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?

Nathan Doromal
  • 3,437
  • 2
  • 24
  • 25
  • 1
    I don't know about Linux but I know Windows will use RAM for the disk cache, and will potentially page out program memory for it. – Mark Ransom Nov 01 '12 at 14:49
  • take a look at this stackoverflow posting. http://stackoverflow.com/questions/578137/can-i-tell-linux-not-to-swap-out-a-particular-processes-memory it describes how to lock a process into memory. – Richard Chambers Nov 01 '12 at 14:50
  • 1
    As an idea. You can write a simple test program that allocates this size of memory inside it and regularily "touches" (uses) this memory. Run this test program for a long time and then run `vmstat` and monitor `the `po` column (Pages paged out to paging space). So you can get an idea how many "page-out" happens on your box. –  Nov 01 '12 at 15:21

1 Answers1

1

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 mlock for more information.

Dirk Holsopple
  • 8,731
  • 1
  • 24
  • 37