diff options
author | Harkrishn Patro <harkrisp@amazon.com> | 2022-07-03 23:18:57 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-04 09:18:57 +0300 |
commit | 0ab885a685101522017021ac2d2b46b42d268f26 (patch) | |
tree | f86373af640b61d9040b8ef9a6bb75f06dd3efd3 /src/pubsub.c | |
parent | 679344a2b064735b1807ccd70ef318a5829a277b (diff) | |
download | redis-0ab885a685101522017021ac2d2b46b42d268f26.tar.gz |
Account sharded pubsub channels memory consumption (#10925)
Account sharded pubsub channels memory consumption in client memory usage
computation to accurately evict client based on the set threshold for `maxmemory-clients`.
Diffstat (limited to 'src/pubsub.c')
-rw-r--r-- | src/pubsub.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/pubsub.c b/src/pubsub.c index 2b063455d..0b909bddd 100644 --- a/src/pubsub.c +++ b/src/pubsub.c @@ -722,3 +722,15 @@ void sunsubscribeCommand(client *c) { } if (clientTotalPubSubSubscriptionCount(c) == 0) c->flags &= ~CLIENT_PUBSUB; } + +size_t pubsubMemOverhead(client *c) { + /* PubSub patterns */ + size_t mem = listLength(c->pubsub_patterns) * sizeof(listNode); + /* Global PubSub channels */ + mem += dictSize(c->pubsub_channels) * sizeof(dictEntry) + + dictSlots(c->pubsub_channels) * sizeof(dictEntry*); + /* Sharded PubSub channels */ + mem += dictSize(c->pubsubshard_channels) * sizeof(dictEntry) + + dictSlots(c->pubsubshard_channels) * sizeof(dictEntry*); + return mem; +} |