Skip to content

Commit 820482b

Browse files
JohnSullyJohn Sully
authored andcommitted
Fix slow to free when low lock contention
1 parent f435218 commit 820482b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/server.cpp

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

0 commit comments

Comments
 (0)