How do I speed up and cache mmap file access over NFS on Linux?
- by Zan Lynx
The server and client are both 64-bit Ubuntu 10.04 LTS.
The application in question is a custom app that uses mmap() for fast random file access. Its ideal state is when the entire file is cached in RAM.
The network connections are really fast 10Gb Ethernet. It is a virtual server blade setup.
It isn't the network connections slowing things down because everything performs superbly when using a virtual disk (iSCSI to the SAN). But when we run the application on a NFS home directory mount, performance goes to the dogs.
It appears that the Linux kernel isn't caching anything. So it is reading every single disk block needed by mmap() accesses over and over and over again.
The NFS mount is done through autofs, which has only default settings. /proc/mounts shows the NFS mount is done with the following options:
rw,relatime,vers=3,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.11.52,mountvers=3,mountproto=tcp,addr=192.168.11.52
How can I make Ubuntu 10.04 cache the file instead of reloading it all the time?