Skip to content

Commit 570bcb5

Browse files
JohnSullyJohn Sully
authored andcommitted
make async rehash configurable
1 parent 68d7510 commit 570bcb5

3 files changed

Lines changed: 3 additions & 1 deletion

File tree

src/config.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2982,6 +2982,7 @@ standardConfig configs[] = {
29822982
createSDSConfig("availability-zone", NULL, MODIFIABLE_CONFIG, 0, g_pserver->sdsAvailabilityZone, "", NULL, NULL),
29832983
createIntConfig("overload-protect-percent", NULL, MODIFIABLE_CONFIG, 0, 200, g_pserver->overload_protect_threshold, 0, INTEGER_CONFIG, NULL, NULL),
29842984
createIntConfig("force-eviction-percent", NULL, MODIFIABLE_CONFIG, 0, 100, g_pserver->force_eviction_percent, 0, INTEGER_CONFIG, NULL, NULL),
2985+
createBoolConfig("enable-async-rehash", NULL, MODIFIABLE_CONFIG, g_pserver->enable_async_rehash, 1, NULL, NULL),
29852986

29862987
#ifdef USE_OPENSSL
29872988
createIntConfig("tls-port", NULL, MODIFIABLE_CONFIG, 0, 65535, g_pserver->tls_port, 0, INTEGER_CONFIG, NULL, updateTLSPort), /* TCP port. */

src/server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2137,7 +2137,7 @@ void databasesCron(bool fMainThread) {
21372137
::dict *dict = g_pserver->db[rehash_db]->dictUnsafeKeyOnly();
21382138
/* Are we async rehashing? And if so is it time to re-calibrate? */
21392139
/* The recalibration limit is a prime number to ensure balancing across threads */
2140-
if (rehashes_per_ms > 0 && async_rehashes < 131 && !cserver.active_defrag_enabled && cserver.cthreads > 1 && dictSize(dict) > 2048 && dictIsRehashing(dict) && !g_pserver->loading && aeLockContention() > 1) {
2140+
if (g_pserver->enable_async_rehash && rehashes_per_ms > 0 && async_rehashes < 131 && !cserver.active_defrag_enabled && cserver.cthreads > 1 && dictSize(dict) > 2048 && dictIsRehashing(dict) && !g_pserver->loading && aeLockContention() > 1) {
21412141
serverTL->rehashCtl = dictRehashAsyncStart(dict, rehashes_per_ms * ((1000 / g_pserver->hz) / 10)); // Estimate 10% CPU time spent in lock contention
21422142
if (serverTL->rehashCtl)
21432143
++async_rehashes;

src/server.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2306,6 +2306,7 @@ struct redisServer {
23062306
rax *errors; /* Errors table */
23072307
int activerehashing; /* Incremental rehash in serverCron() */
23082308
int active_defrag_running; /* Active defragmentation running (holds current scan aggressiveness) */
2309+
int enable_async_rehash = 1; /* Should we use the async rehash feature? */
23092310
int cronloops; /* Number of times the cron function run */
23102311
char runid[CONFIG_RUN_ID_SIZE+1]; /* ID always different at every exec. */
23112312
int sentinel_mode; /* True if this instance is a Sentinel. */

0 commit comments

Comments
 (0)