The key point when performing I/O is realizing that the underlying storage (disk) hardware is much, much slower than RAM. So, devising strategies to minimize going to the disk and working more from memory will always help. In fact, both the library layer (we have already discussed studio buffering in some detail), and the OS (via the page cache and other features within the block I/O layers, and, in fact, even within modern hardware) will perform a lot of work to ensure this. For the (systems) application developer, a few suggestions to consider are made next.
If feasible, use large buffers (to hold the data read or to be written) when performing I/O operations upon a file—but how large? A good rule of thumb is to use the same size for the local buffer as the I/O block size of the filesystem upon which the file resides (in fact, this field...