Giving hints to the kernel on file I/O patterns

We now understand that the kernel goes ahead and caches all file I/O within its page cache; this is good for performance. It's useful to think about an example: an application sets up and performs streaming reads on a very large video file (to display it within some app window to the user; we shall assume the particular video file is being accessed for the first time). It's easy to understand that, in general, caching a file as it's read from the disk helps, but here, in this particular case, it would not really help much, as, the first time, we still have to first go to the disk and read it in. So, we shrug our shoulders and continue coding it in the usual way, sequentially reading in chunks ...

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.