• Wang Yuan's avatar
    Use sync_file_range to optimize fsync if possible (#9409) · 9a0c0617
    Wang Yuan authored
    We implement incremental data sync in rio.c by call fsync, on slow disk, that may cost a lot of time,
    sync_file_range could provide async fsync, so we could serialize key/value and sync file data at the same time.
    
    > one tip for sync_file_range usage: http://lkml.iu.edu/hypermail/linux/kernel/1005.2/01845.html
    
    Additionally, this change avoids a single large write to be used, which can result in a mass of dirty
    pages in the kernel (increasing the risk of someone else's write to block).
    
    On HDD, current solution could reduce approximate half of dumping RDB time,
    this PR costs 50s for dump 7.7G rdb but unstable branch costs 93s.
    On NVME SSD, this PR can't reduce much time,  this PR costs 40s, unstable branch costs 48s.
    
    Moreover, I find calling data sync every 4MB is better than 32MB.
    9a0c0617
server.h 131 KB