summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2019-04-30 15:39:27 +0200
committerantirez <antirez@gmail.com>2019-04-30 15:39:27 +0200
commit2c60c47e066e8a8cc6851f7346c2fff6f40f42ea (patch)
tree6e4c17682cb1fd1282566988d65d15f43d703fb8
parent30d8c0fe4ae2d1aa1bb4c627fc148b55a6c8f2c8 (diff)
downloadredis-2c60c47e066e8a8cc6851f7346c2fff6f40f42ea.tar.gz
Threaded IO: ability to disable reads from threaded path.
-rw-r--r--src/networking.c3
-rw-r--r--src/server.c1
-rw-r--r--src/server.h2
3 files changed, 5 insertions, 1 deletions
diff --git a/src/networking.c b/src/networking.c
index 74bd0f13d..651dbdb8a 100644
--- a/src/networking.c
+++ b/src/networking.c
@@ -2723,6 +2723,7 @@ int handleClientsWithPendingWritesUsingThreads(void) {
* pending read clients and flagged as such. */
int postponeClientRead(client *c) {
if (io_threads_active &&
+ server.io_threads_do_reads &&
!(c->flags & (CLIENT_MASTER|CLIENT_SLAVE|CLIENT_PENDING_READ)))
{
c->flags |= CLIENT_PENDING_READ;
@@ -2734,7 +2735,7 @@ int postponeClientRead(client *c) {
}
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);
if (processed == 0) return 0;
diff --git a/src/server.c b/src/server.c
index e0c48b097..2643d7266 100644
--- a/src/server.c
+++ b/src/server.c
@@ -2315,6 +2315,7 @@ void initServerConfig(void) {
server.always_show_logo = CONFIG_DEFAULT_ALWAYS_SHOW_LOGO;
server.lua_time_limit = LUA_SCRIPT_TIME_LIMIT;
server.io_threads_num = CONFIG_DEFAULT_IO_THREADS_NUM;
+ server.io_threads_do_reads = CONFIG_DEFAULT_IO_THREADS_DO_READS;
server.lruclock = getLRUClock();
resetServerSaveParams();
diff --git a/src/server.h b/src/server.h
index c088d356a..3987ab5fc 100644
--- a/src/server.h
+++ b/src/server.h
@@ -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_DBNUM 16
#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 CRON_DBS_PER_CALL 16
#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
queries. Will still serve RESP2 queries. */
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 */
int loading; /* We are loading data from disk if true */