#1941 What is diff between sync and flush?

Akcelisto Sun 8 Jul 2012

When I write to file over sys::OutStream, what is diff between sync and flush?

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.

Login or Signup to reply.