diff options
author | zhenwei pi <pizhenwei@bytedance.com> | 2020-05-02 20:05:39 +0800 |
---|---|---|
committer | zhenwei pi <pizhenwei@bytedance.com> | 2020-05-02 21:19:47 +0800 |
commit | 1a0deab2a548fa306171f03439e858c00836fe69 (patch) | |
tree | 776c4d73d8fa4f0e0dfa6f7c386327e9939186ea /src/config.h | |
parent | 365316aa59545d90de4e105cec57f22aa5b52ff9 (diff) | |
download | redis-1a0deab2a548fa306171f03439e858c00836fe69.tar.gz |
Support setcpuaffinity on linux/bsd
Currently, there are several types of threads/child processes of a
redis server. Sometimes we need deeply optimise the performance of
redis, so we would like to isolate threads/processes.
There were some discussion about cpu affinity cases in the issue:
https://github.com/antirez/redis/issues/2863
So implement cpu affinity setting by redis.conf in this patch, then
we can config server_cpulist/bio_cpulist/aof_rewrite_cpulist/
bgsave_cpulist by cpu list.
Examples of cpulist in redis.conf:
server_cpulist 0-7:2 means cpu affinity 0,2,4,6
bio_cpulist 1,3 means cpu affinity 1,3
aof_rewrite_cpulist 8-11 means cpu affinity 8,9,10,11
bgsave_cpulist 1,10-11 means cpu affinity 1,10,11
Test on linux/freebsd, both work fine.
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Diffstat (limited to 'src/config.h')
-rw-r--r-- | src/config.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/config.h b/src/config.h index 40dc683ce..a322ce354 100644 --- a/src/config.h +++ b/src/config.h @@ -244,4 +244,10 @@ int pthread_setname_np(const char *name); #endif #endif +/* Check if we can use setcpuaffinity(). */ +#if (defined __linux || defined __NetBSD__ || defined __FreeBSD__ || defined __OpenBSD__) +#define USE_SETCPUAFFINITY +void setcpuaffinity(const char *cpulist); +#endif + #endif |