diff --git a/src/object.c b/src/object.c index 9a0b50c01..3eef47c5d 100644 --- a/src/object.c +++ b/src/object.c @@ -1233,6 +1233,11 @@ struct redisMemOverhead *getMemoryOverheadData(void) { mh->db[mh->num_dbs].overhead_ht_expires = mem; mem_total+=mem; + /* Account for the slot to keys map in cluster mode */ + mem = dictSize(db->dict) * dictMetadataSize(db->dict); + mh->db[mh->num_dbs].overhead_ht_slot_to_keys = mem; + mem_total+=mem; + mh->num_dbs++; } @@ -1523,6 +1528,7 @@ NULL size_t usage = objectComputeSize(c->argv[2],dictGetVal(de),samples,c->db->id); usage += sdsZmallocSize(dictGetKey(de)); usage += sizeof(dictEntry); + usage += dictMetadataSize(c->db->dict); addReplyLongLong(c,usage); } else if (!strcasecmp(c->argv[1]->ptr,"stats") && c->argc == 2) { struct redisMemOverhead *mh = getMemoryOverheadData(); @@ -1560,15 +1566,19 @@ NULL char dbname[32]; snprintf(dbname,sizeof(dbname),"db.%zd",mh->db[j].dbid); addReplyBulkCString(c,dbname); - addReplyMapLen(c,2); + addReplyMapLen(c,3); addReplyBulkCString(c,"overhead.hashtable.main"); addReplyLongLong(c,mh->db[j].overhead_ht_main); addReplyBulkCString(c,"overhead.hashtable.expires"); addReplyLongLong(c,mh->db[j].overhead_ht_expires); + + addReplyBulkCString(c,"overhead.hashtable.slot-to-keys"); + addReplyLongLong(c,mh->db[j].overhead_ht_slot_to_keys); } + addReplyBulkCString(c,"overhead.total"); addReplyLongLong(c,mh->overhead_total); diff --git a/src/server.c b/src/server.c index 47bf1628e..e7cf5740b 100644 --- a/src/server.c +++ b/src/server.c @@ -344,6 +344,8 @@ int dictExpandAllowed(size_t moreMem, double usedRatio) { * belonging to the same cluster slot. See the Slot to Key API in cluster.c. */ size_t dictEntryMetadataSize(dict *d) { UNUSED(d); + /* NOTICE: this also affect overhead_ht_slot_to_keys in getMemoryOverheadData. + * If we ever add non-cluster related data here, that code must be modified too. */ return server.cluster_enabled ? sizeof(clusterDictEntryMetadata) : 0; } diff --git a/src/server.h b/src/server.h index c281ac30a..792eb30a1 100644 --- a/src/server.h +++ b/src/server.h @@ -1267,6 +1267,7 @@ struct redisMemOverhead { size_t dbid; size_t overhead_ht_main; size_t overhead_ht_expires; + size_t overhead_ht_slot_to_keys; } *db; };