What does sync() _really_ do?

Steinar Kj{rnsr|d steinar at ifi.uio.no
Thu Dec 13 22:31:07 AEST 1990


The above subject and imposed question may seem trivial, but I have so far
failed to find the answer (I browsed through the 4.3 book by McKusick, Karels
and Quarterman, references to pertinent pages here are welcome). The question
arised when a disk vendor presented results from a benchmark which purpose
was to measure read/write transfer rates for his drive. His scenario
was this:

 - a stand alone BSD (SunOS 4.0.3 I think) box in single user mode
 - no other disk activity in the system

The test program looked something like this:

 - <write a HUUUUGE file and measure the write transfer rate>
 - sync(); sync(); sync();
 - <read the same file back again and measure the read transfer rate>
 
Both read and write of the file use normal IO (asynchronous) operations which
therefore involves the buffer cache. The disk vendor's assumption is that
the three sync() calls will guarantee that the read pass of the test will
read data  off the media, not from the buffer cache, while I say that
although the sync() calls force dirty pages in the buffer cache to be written
to the disk, you have no guarantee that those pages also will be wiped out
from the cache. I find this especially true since there are no other
disk activity in the system at the time when the test is running. What would
be the purpose of really clearing the cache when you have nothing to replace
the cleared pages with?

Who are right?


 +==================================================================+
 !                                                                  !
 !      Steinar Kjaernsroed, 					    !
 !	Dpt. of Informatics,					    !
 !      University of Oslo,					    !
 !      P.O.Box 1080, Blindern,					    !
 !	0316, Oslo 3, 						    !
 !	NORWAY							    !
 !                                                                  !
 !      Phone:             047+2+453460 (work), 		    !
 !      Email:             steinar at ifi.uio.no      (Internet)       !
 !                         ..!mcsun!ifi!steinar 	(UUCP)	    !
 !          							    !
 +==================================================================+

 



More information about the Comp.unix.internals mailing list