summaryrefslogtreecommitdiff
path: root/src/tracking.c
diff options
context:
space:
mode:
authorHarkrishn Patro <harkrisp@amazon.com>2022-12-06 22:26:56 -0800
committerGitHub <noreply@github.com>2022-12-07 08:26:56 +0200
commitc0267b3fa5808df475dec83c956b9a2bec112b90 (patch)
treefd3913a9b0d1fe8cbb08a0618ea719db886a9eb7 /src/tracking.c
parent8a315fc285fc54c678b97107a02ee1627f2c1ebf (diff)
downloadredis-c0267b3fa5808df475dec83c956b9a2bec112b90.tar.gz
Optimize client memory usage tracking operation while client eviction is disabled (#11348)
## Issue During the client input/output buffer processing, the memory usage is incrementally updated to keep track of clients going beyond a certain threshold `maxmemory-clients` to be evicted. However, this additional tracking activity leads to unnecessary CPU cycles wasted when no client-eviction is required. It is applicable in two cases. * `maxmemory-clients` is set to `0` which equates to no client eviction (applicable to all clients) * `CLIENT NO-EVICT` flag is set to `ON` which equates to a particular client not applicable for eviction. ## Solution * Disable client memory usage tracking during the read/write flow when `maxmemory-clients` is set to `0` or `client no-evict` is `on`. The memory usage is tracked only during the `clientCron` i.e. it gets periodically updated. * Cleanup the clients from the memory usage bucket when client eviction is disabled. * When the maxmemory-clients config is enabled or disabled at runtime, we immediately update the memory usage buckets for all clients (tested scanning 80000 took some 20ms) Benchmark shown that this can improve performance by about 5% in certain situations. Co-authored-by: Oran Agra <oran@redislabs.com>
Diffstat (limited to 'src/tracking.c')
-rw-r--r--src/tracking.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/tracking.c b/src/tracking.c
index 1b04c0626..d62eb736b 100644
--- a/src/tracking.c
+++ b/src/tracking.c
@@ -311,7 +311,7 @@ void sendTrackingMessage(client *c, char *keyname, size_t keylen, int proto) {
addReplyArrayLen(c,1);
addReplyBulkCBuffer(c,keyname,keylen);
}
- updateClientMemUsage(c);
+ updateClientMemUsageAndBucket(c);
}
/* This function is called when a key is modified in Redis and in the case