Threaded IO: ability to disable reads from threaded path.

This commit is contained in:
antirez 2019-04-30 15:39:27 +02:00
parent 6e29b364a8
commit 50b09bc408
3 changed files with 5 additions and 1 deletions

View File

@ -2723,6 +2723,7 @@ int handleClientsWithPendingWritesUsingThreads(void) {
* pending read clients and flagged as such. */ * pending read clients and flagged as such. */
int postponeClientRead(client *c) { int postponeClientRead(client *c) {
if (io_threads_active && if (io_threads_active &&
server.io_threads_do_reads &&
!(c->flags & (CLIENT_MASTER|CLIENT_SLAVE|CLIENT_PENDING_READ))) !(c->flags & (CLIENT_MASTER|CLIENT_SLAVE|CLIENT_PENDING_READ)))
{ {
c->flags |= CLIENT_PENDING_READ; c->flags |= CLIENT_PENDING_READ;
@ -2734,7 +2735,7 @@ int postponeClientRead(client *c) {
} }
int handleClientsWithPendingReadsUsingThreads(void) { int handleClientsWithPendingReadsUsingThreads(void) {
if (!io_threads_active) return 0; if (!io_threads_active || !server.io_threads_do_reads) return 0;
int processed = listLength(server.clients_pending_read); int processed = listLength(server.clients_pending_read);
if (processed == 0) return 0; if (processed == 0) return 0;

View File

@ -2315,6 +2315,7 @@ void initServerConfig(void) {
server.always_show_logo = CONFIG_DEFAULT_ALWAYS_SHOW_LOGO; server.always_show_logo = CONFIG_DEFAULT_ALWAYS_SHOW_LOGO;
server.lua_time_limit = LUA_SCRIPT_TIME_LIMIT; server.lua_time_limit = LUA_SCRIPT_TIME_LIMIT;
server.io_threads_num = CONFIG_DEFAULT_IO_THREADS_NUM; server.io_threads_num = CONFIG_DEFAULT_IO_THREADS_NUM;
server.io_threads_do_reads = CONFIG_DEFAULT_IO_THREADS_DO_READS;
server.lruclock = getLRUClock(); server.lruclock = getLRUClock();
resetServerSaveParams(); resetServerSaveParams();

View File

@ -88,6 +88,7 @@ typedef long long mstime_t; /* millisecond time type. */
#define CONFIG_DEFAULT_CLIENT_TIMEOUT 0 /* Default client timeout: infinite */ #define CONFIG_DEFAULT_CLIENT_TIMEOUT 0 /* Default client timeout: infinite */
#define CONFIG_DEFAULT_DBNUM 16 #define CONFIG_DEFAULT_DBNUM 16
#define CONFIG_DEFAULT_IO_THREADS_NUM 1 /* Single threaded by default */ #define CONFIG_DEFAULT_IO_THREADS_NUM 1 /* Single threaded by default */
#define CONFIG_DEFAULT_IO_THREADS_DO_READS 0 /* Read + parse from threads? */
#define CONFIG_MAX_LINE 1024 #define CONFIG_MAX_LINE 1024
#define CRON_DBS_PER_CALL 16 #define CRON_DBS_PER_CALL 16
#define NET_MAX_WRITES_PER_EVENT (1024*64) #define NET_MAX_WRITES_PER_EVENT (1024*64)
@ -1069,6 +1070,7 @@ struct redisServer {
int gopher_enabled; /* If true the server will reply to gopher int gopher_enabled; /* If true the server will reply to gopher
queries. Will still serve RESP2 queries. */ queries. Will still serve RESP2 queries. */
int io_threads_num; /* Number of IO threads to use. */ int io_threads_num; /* Number of IO threads to use. */
int io_threads_do_reads; /* Read and parse from IO threads? */
/* RDB / AOF loading information */ /* RDB / AOF loading information */
int loading; /* We are loading data from disk if true */ int loading; /* We are loading data from disk if true */