From aa64a260fc14a6442117ec754e79c1ffe225cb20 Mon Sep 17 00:00:00 2001 From: John Sully Date: Thu, 8 Apr 2021 19:52:38 +0000 Subject: [PATCH] Make prefetch configurable Former-commit-id: 3b660347d70cc25d57119080bd43fb4671e36488 --- src/config.cpp | 1 + src/networking.cpp | 4 ++-- src/server.h | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index 99505d444..9d7f14007 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -2535,6 +2535,7 @@ standardConfig configs[] = { createBoolConfig("use-fork", NULL, IMMUTABLE_CONFIG, cserver.fForkBgSave, 0, NULL, NULL), createBoolConfig("allow-write-during-load", NULL, MODIFIABLE_CONFIG, g_pserver->fWriteDuringActiveLoad, 0, NULL, NULL), createBoolConfig("io-threads-do-reads", NULL, IMMUTABLE_CONFIG, fDummy, 0, NULL, NULL), + createBoolConfig("prefetch-enabled", NULL, MODIFIABLE_CONFIG, g_pserver->prefetch_enabled, 1, NULL, NULL), /* String Configs */ createStringConfig("aclfile", NULL, IMMUTABLE_CONFIG, ALLOW_EMPTY_STRING, g_pserver->acl_filename, "", NULL, NULL), diff --git a/src/networking.cpp b/src/networking.cpp index 72d08cc80..c6daefe1f 100644 --- a/src/networking.cpp +++ b/src/networking.cpp @@ -2353,7 +2353,7 @@ void parseClientCommandBuffer(client *c) { } } - size_t cqueries = c->vecqueuedcmd.size(); + size_t cqueriesStart = c->vecqueuedcmd.size(); if (c->reqtype == PROTO_REQ_INLINE) { if (processInlineBuffer(c) != C_OK) break; } else if (c->reqtype == PROTO_REQ_MULTIBULK) { @@ -2369,7 +2369,7 @@ void parseClientCommandBuffer(client *c) { } /* Prefetch outside the lock for better perf */ - if (cqueries < c->vecqueuedcmd.size() && !GlobalLocksAcquired()) { + if (g_pserver->prefetch_enabled && cqueriesStart < c->vecqueuedcmd.size() && !GlobalLocksAcquired()) { auto &query = c->vecqueuedcmd.back(); if (query.argc > 0 && query.argc == query.argcMax) { c->db->prefetchKeysAsync(c, query); diff --git a/src/server.h b/src/server.h index 449bc77ee..9eed26e95 100644 --- a/src/server.h +++ b/src/server.h @@ -2391,6 +2391,8 @@ struct redisServer { char *aof_rewrite_cpulist; /* cpu affinity list of aof rewrite process. */ char *bgsave_cpulist; /* cpu affinity list of bgsave process. */ + int prefetch_enabled = 1; + long long repl_batch_offStart = -1; long long repl_batch_idxStart = -1;