Keep a file in memory an any cost

JD jd1008 at gmail.com
Wed May 11 18:58:43 UTC 2011


On 05/11/11 11:19, Alain Spineux wrote:
> Hello I have a file, that is an index, it is open all the time by the
> application,
> but sometime the access are slow because the file was moved out of the cache.
>
> How can I keep it in memory all the time ?
> I can read it at regular interval, but this is a little over kill ?
>
> Any idea
>
> thanks.
>
>
mlock(2):
int mlock(const void *addr, size_t len);
can lock user virtual pages to memory (if user has the privileges).
But when it comes to a file, you have no way of knowing the VA of the 
pages in
which a file is stored, so you will not be able to call mlock(2) with 
the right VA.
Furthermore, a file is not necessarily all brought into memory IN CONTIGUOUS
VIRTUAL PAGES of the system's filecache. So, obviously, mlock would not 
help.




More information about the users mailing list