<File as Write>::flush should call fsync

I noticed <File as Write>::flush on unix is currently a no-op. I was expecting it to call fsync. Thoughts?

Fsync is an extremely expensive operation. Writers are commonly used in generic contexts where flush is interpreted as the minimal amount of work to get the data out to where it needs to go.

In the land of C, fflush hands the contents of the write buffer in-process to the OS. fsync is a related but different function. It’s a syscall that asks the OS to flush OS buffers to disk.

<File as Write>::flush should probably do some flushing of the internal buffers but no, it’s not the same as fsync.

1 Like

Wow, I just tested this, and you’re right. I didn’t think I could be that wrong :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.