| ▲ | millipede 4 hours ago | |||||||||||||||||||||||||
I always wondered why the fsync has to be lazy. It seems like the fsync's can be bundled up together, and the notification messages held for a few millis while the write completes. Similar to TCP corking. There doesn't need to be one fsync per consensus. | ||||||||||||||||||||||||||
| ▲ | kbenson 44 minutes ago | parent | next [-] | |||||||||||||||||||||||||
That was my immediate thought as well, under the assumption the lazy fsync is for performance. I imagine in some situations, delaying the write until the write confirmation actually happens is okay (depending on delay), but it also occurred to me that if you delay enough, and you have a busy enough system, and your time to send the message is small enough, the number of open connections you need to keep open can be some small or large multiple of the amount you would need without delaying the confirmation message to actual write time. | ||||||||||||||||||||||||||
| ▲ | aphyr 3 hours ago | parent | prev | next [-] | |||||||||||||||||||||||||
Yes, good call! You can batch up multiple operations into a single call to fsync. You can also tune the number of milliseconds or bytes you're willing to buffer before calling `fsync` to balance latency and throughput. This is how databases like Postgres work by default--see the `commit_delay` option here: https://www.postgresql.org/docs/8.1/runtime-config-wal.html | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||
| ▲ | senderista an hour ago | parent | prev [-] | |||||||||||||||||||||||||
In practice, there must be a delay (from batching) if you fsync every transaction before acknowledging commit. The database would be unusably slow otherwise. | ||||||||||||||||||||||||||