Re:Why not mmap?
by Andys on Thursday May 19, 2011 @07:11AM
(#2563557)
Actually, in my experience, read-ahead into cache is what the OS does NOT handle for you. To get file-level read ahead in *nix you need to use normal IO syscalls. mmap is only suitable for completely random IO.
[ Parent
| on HN ]
In instances where you may have many processes reading the same files in some sort of access pattern and you know they need to be in disk cache you can use fadvise[1]. It'll let you tell the kernel that I am going to need that file, why don't you go ahead and get it in the disk cache.
For many applications this is not the right way to go, but for completely predictable access patterns on a machine that is devoted to it, it can save the day.