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/server.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/server.h')
-rw-r--r-- | src/server.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/server.h b/src/server.h index 41d767e13..af435b148 100644 --- a/src/server.h +++ b/src/server.h @@ -1433,6 +1433,11 @@ struct redisServer { int tls_replication; int tls_auth_clients; redisTLSContextConfig tls_ctx_config; + /* cpu affinity */ + char *server_cpulist; /* cpu affinity list of redis server main/io thread. */ + char *bio_cpulist; /* cpu affinity list of bio thread. */ + char *aof_rewrite_cpulist; /* cpu affinity list of aof rewrite process. */ + char *bgsave_cpulist; /* cpu affinity list of bgsave process. */ }; typedef struct pubsubPattern { @@ -1585,6 +1590,7 @@ void exitFromChild(int retcode); size_t redisPopcount(void *s, long count); void redisSetProcTitle(char *title); int redisCommunicateSystemd(const char *sd_notify_msg); +void redisSetCpuAffinity(const char *cpulist); /* networking.c -- Networking and Client related operations */ client *createClient(connection *conn); |