News for hackers. Stuff that matters.
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.
Re:Why not mmap? by ghotli on Thursday May 19, 2011 @08:12AM (#2563651)
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.

[1] http://linux.die.net/man/2/fadvise

Re:Why not mmap? by rbranson on Thursday May 19, 2011 @12:53PM (#2564552)
There is an madvise() syscall that roughly translates into an fadvise() for memory-mapped regions as well.