read vs. mmap (or io vs. page faults)

Matthew Dillon dillon at
Mon Jun 21 22:59:43 GMT 2004

:ask for 8k, but the system will fetch the next 64k of data.  Problem is
:the system does nothing until you read the next 8k past the 64k
:alreqady read in, then it jumps up and grabs the next 64k.  You're
:still waiting on I/O every 8th read.  Ideally it would do an async
:	Dan Nelson
:	dnelson at

    No, this isn't true.  The system places a marker 8K or 16K before the
    last read block and initiates the next read-ahead before you exhaust the
    first one.

    For mapped data the system intentionally does not map the page table entry
    for a page or two before the end of the read ahead in order to force a
    page fault so it can initiate the next read ahead.

    For read data the system marks a buffer near the end of the read ahead
    so when read encounters it the system knows to queue then next read-ahead.

    Also, for that matter, remember that the hard drives themselves generally
    cache whole tracks and do their own read-ahead.  This is why dd'ing a 
    large file usually results in the maximum transfer rate the hard drive
    can do.

					Matthew Dillon 
					<dillon at>

More information about the freebsd-current mailing list