Home
Software
TIL
Contact Me
File sync is very slow
I’m working on a Go library appendstore for append-only store of lots of things in a single file.
To make things as robust as possible I was calling os.File.Sync() after each append. Sync() is waiting until the data is acknowledged as truly, really written to disk (as opposed to maybe floating somewhere in disk drive’s write buffer).
Oh boy, is it slow. A test of appending 1000 records would take over 5 seconds.
After removing the Sync() it would drop to 5 milliseconds. 1000x faster.
I made sync optional - it’s now up to the user of the library to pick it, defaults to non-sync.
Is it unsafe now? Well, the reality is that it probably doesn’t matter. I don’t think lots of software does the sync due to slowness and the world still runs.
til programming
Jul 17 2025

Home
Software
TIL
Contact Me