summaryrefslogtreecommitdiff
path: root/src/config.h
diff options
context:
space:
mode:
authorWang Yuan <wangyuan21@baidu.com>2021-08-30 15:24:53 +0800
committerGitHub <noreply@github.com>2021-08-30 10:24:53 +0300
commit9a0c0617f10ebb6cd5bf82f5f4f7049e7ff0a3ce (patch)
treefbbf767d9291f4e0ef1e49064320246e9390cba9 /src/config.h
parentaefbc23451ae8d0c7503f2c3cb014bfd5b07b4ed (diff)
downloadredis-9a0c0617f10ebb6cd5bf82f5f4f7049e7ff0a3ce.tar.gz
Use sync_file_range to optimize fsync if possible (#9409)
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.
Diffstat (limited to 'src/config.h')
-rw-r--r--src/config.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/config.h b/src/config.h
index 4700e7208..5a4223fbd 100644
--- a/src/config.h
+++ b/src/config.h
@@ -120,6 +120,7 @@
/* Define rdb_fsync_range to sync_file_range() on Linux, otherwise we use
* the plain fsync() call. */
#if (defined(__linux__) && defined(SYNC_FILE_RANGE_WAIT_BEFORE))
+#define HAVE_SYNC_FILE_RANGE 1
#define rdb_fsync_range(fd,off,size) sync_file_range(fd,off,size,SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE)
#else
#define rdb_fsync_range(fd,off,size) fsync(fd)