When I write to file over sys::OutStream, what is diff between sync and flush?
brianSun 8 Jul 2012
Flush just flushes any buffered bytes out to the file/socket.
Sync is a file system fsync which forces the OS and disk controller to flush its buffers to the physical media. Typically fsync is really expensive b/c it has to flush pending changes made by any process to ensure file system state is completely up to date. It is typically only used by by databases that need to guarantee something has really been written all the way out to disk.
So think of flush as process level and sync as system/OS level.
Akcelisto Sun 8 Jul 2012
When I write to file over
sys::OutStream
, what is diff betweensync
andflush
?brian Sun 8 Jul 2012
Flush just flushes any buffered bytes out to the file/socket.
Sync is a file system fsync which forces the OS and disk controller to flush its buffers to the physical media. Typically fsync is really expensive b/c it has to flush pending changes made by any process to ensure file system state is completely up to date. It is typically only used by by databases that need to guarantee something has really been written all the way out to disk.
So think of flush as process level and sync as system/OS level.