Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

actually since none of its tests ask to sync the data onto the disk, he might just be measuring each method efficiency in creating dirty pages.

of course that depends on the amount of RAM the system has, and how the kernel VM parameters are tuned (sysctl vm.dirty_*)

just add a fdatasync() call and you will take into account the time it takes to flush all dirty pages into the disk.



[deleted]


write() guarantees that the bits have been sent to the disk, and the disk reports that they have been written (or, if a nonvolatile cache is available, it is in the cache).

At least for Linux, I think that's dangerously untrue. On my machine, 'man write' even includes an explicit warning:

   A successful return from write() does not make any 
   guarantee that data has been  committed to  disk.
   In  fact, on some buggy implementations, it does not
   even guarantee that space has successfully been reserved
   for the data.  The only way to be sure is to call
   fsync(2) after you are done writing all your data.
There are ways to configure a file system so this is not the case, but they are rare. Is there a reference you could point to that would clarify what you are saying?


I am >99% confident that this is false for default setups. write() itself may return even before a command has been sent to the physical disk, and definitely before the disk reports that it is done. Waiting for the disk on every write() would kill the performance for most programs.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: