mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
Report slot to keys map size in MEMORY STATS in cluster mode (#10017)
Report slot to keys map size in MEMORY STATS in cluster mode Report dictMetadataSize in MEMORY USAGE command as well
This commit is contained in:
parent
45a155bd0f
commit
09c668f220
12
src/object.c
12
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);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user