safekeeper: avoid or optimize segment fsyncs #9664
Labels
a/performance
Area: relates to performance of the system
c/storage/safekeeper
Component: storage: safekeeper
The WAL receiver attempts to batch writes and avoid fsyncs via
NoFlushAppendRequest
, only flushing every second:neon/safekeeper/src/receive_wal.rs
Lines 537 to 543 in 123816e
However, we unconditionally fsync after writing out a complete 16 MB segment:
neon/safekeeper/src/wal_storage.rs
Lines 297 to 298 in b54b632
We also unconditionally fsync 3 times when we create a new segment:
neon/safekeeper/src/wal_storage.rs
Line 270 in 4282061
This implies that we'll fsync four times after every 16 MB. If we want to hit 1 GB/s, that's 256 fsyncs. We should try to optimize this.
Also note that the control file is fsynced every time the commit LSN crosses a segment boundary. That's an additional 64 fsyncs per second. See #9663.
The text was updated successfully, but these errors were encountered: