madvise() vs posix_fadvise()
Dmitry Sivachenko
trtrmitya at gmail.com
Mon Mar 24 12:03:09 UTC 2014
On 21 марта 2014 г., at 20:27, Trond Endrestøl <Trond.Endrestol at fagskolen.gjovik.no> wrote:
> On Fri, 21 Mar 2014 18:56+0400, Dmitry Sivachenko wrote:
>
>> 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?
>
> Although a bit dangerous, mlock(2) might be your ticket. That system
> call prevents your memory region from being swapped/paged away from
> physical memory.
>
I know about mlock(2), it is a bit overkill.
Can someone please explain the difference between madvise(MADV_WILLNEED) and posix_fadvise(POSIX_FADV_WILLNEED)?
More information about the freebsd-hackers
mailing list