[NTLUG:Discuss] Disk I/O timings.

Steve Baker sjbaker1 at airmail.net
Fri Dec 7 19:11:57 CST 2001


David Neeley wrote:
> 
> Isn't it true that for many drive requests, the entire file is not read
> during the first request? Is it not also true that the drive reads *more*
> than the request requires so that subsequent requests for data in that
> immediate vacinity are more likely to be in cache?

Yes - that would be true for a 'read()' type request.  It would be silly
to transfer a whole disk block over from the hard drive and then throw
away all but the one byte that the program asked for.

However, I don't use 'read()' in this context.  I used 'mmap' which says
something like "Map the N bytes of the file into this block of RAM"...in
that case, the RAM *is* the cache and it's treated very much like virtual
memory.  As you access the RAM, you cause a page fault which the kernel
traps and uses to allocate physical ram into which the requested section
of the file is loaded.

> Unless Linux is quite different than other systems, the initial access
> often does not read the entire file into system memory--cache is the
> enabler for this.

No - Linux is not unusual in that respect...perhaps unusual in that it
automatically uses *ALL* of free RAM for the cache instead of just some
fixed sized chunk.

----------------------------- Steve Baker -------------------------------
Mail : <sjbaker1 at airmail.net>   WorkMail: <sjbaker at link.com>
URLs : http://www.sjbaker.org
       http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net
       http://prettypoly.sf.net http://freeglut.sf.net
       http://toobular.sf.net   http://lodestone.sf.net




More information about the Discuss mailing list