madvise() vs posix_fadvise()

Dmitry Sivachenko trtrmitya at gmail.com
Fri Mar 21 14:57:01 UTC 2014


Hello!

I have a program which uses large data files (read-only, via mmap()).

These machines have a bit more RAM that these files occupy, so it is possible to have all these data in memory.

What techniques should I use to promote this data not to be purged from RAM:
-- madvise(MADV_WILLNEED)
-- posix_fadvise(POSIX_FADV_WILLNEED)
-- both?

Some parts of this mmap()ed data is frequently accessed, some is not, and I see that rarely accessed regions are purged from RAM.  I want disk cache (program writes large log files) to have lower priority, so disk cache does not purge mmaped regions from memory.

Thanks.


More information about the freebsd-hackers mailing list