mirror of
https://github.com/fluencelabs/redis
synced 2025-03-20 09:30:55 +00:00
Provide percentage of memory peak used info.
This commit is contained in:
parent
309c2bcd1b
commit
d9325ac6c8
10
src/object.c
10
src/object.c
@ -810,6 +810,7 @@ struct redisMemOverhead *getMemoryOverheadData(void) {
|
||||
|
||||
mh->total_allocated = zmalloc_used;
|
||||
mh->startup_allocated = server.initial_memory_usage;
|
||||
mh->peak_allocated = server.stat_peak_memory;
|
||||
mem_total += server.initial_memory_usage;
|
||||
|
||||
mem = 0;
|
||||
@ -889,6 +890,7 @@ struct redisMemOverhead *getMemoryOverheadData(void) {
|
||||
if (zmalloc_used > mh->startup_allocated)
|
||||
net_usage = zmalloc_used - mh->startup_allocated;
|
||||
mh->dataset_perc = (float)mh->dataset*100/net_usage;
|
||||
mh->peak_perc = (float)zmalloc_used*100/mh->peak_allocated;
|
||||
|
||||
return mh;
|
||||
}
|
||||
@ -988,7 +990,10 @@ void memoryCommand(client *c) {
|
||||
} else if (!strcasecmp(c->argv[1]->ptr,"overhead") && c->argc == 2) {
|
||||
struct redisMemOverhead *mh = getMemoryOverheadData();
|
||||
|
||||
addReplyMultiBulkLen(c,(9+mh->num_dbs)*2);
|
||||
addReplyMultiBulkLen(c,(11+mh->num_dbs)*2);
|
||||
|
||||
addReplyBulkCString(c,"peak.allocated");
|
||||
addReplyLongLong(c,mh->peak_allocated);
|
||||
|
||||
addReplyBulkCString(c,"total.allocated");
|
||||
addReplyLongLong(c,mh->total_allocated);
|
||||
@ -1030,6 +1035,9 @@ void memoryCommand(client *c) {
|
||||
addReplyBulkCString(c,"dataset.percentage");
|
||||
addReplyDouble(c,mh->dataset_perc);
|
||||
|
||||
addReplyBulkCString(c,"peak.percentage");
|
||||
addReplyDouble(c,mh->peak_perc);
|
||||
|
||||
freeMemoryOverheadData(mh);
|
||||
} else if (!strcasecmp(c->argv[1]->ptr,"allocator-stats") && c->argc == 2) {
|
||||
#if defined(USE_JEMALLOC)
|
||||
|
@ -2837,6 +2837,7 @@ sds genRedisInfoString(char *section) {
|
||||
"used_memory_rss_human:%s\r\n"
|
||||
"used_memory_peak:%zu\r\n"
|
||||
"used_memory_peak_human:%s\r\n"
|
||||
"used_memory_peak_perc:%.2f%%\r\n"
|
||||
"used_memory_overhead:%zu\r\n"
|
||||
"used_memory_startup:%zu\r\n"
|
||||
"used_memory_dataset:%zu\r\n"
|
||||
@ -2857,6 +2858,7 @@ sds genRedisInfoString(char *section) {
|
||||
used_memory_rss_hmem,
|
||||
server.stat_peak_memory,
|
||||
peak_hmem,
|
||||
mh->peak_perc,
|
||||
mh->overhead_total,
|
||||
mh->startup_allocated,
|
||||
mh->dataset,
|
||||
|
@ -772,6 +772,7 @@ typedef struct redisOpArray {
|
||||
/* This structure is returned by the getMemoryOverheadData() function in
|
||||
* order to return memory overhead information. */
|
||||
struct redisMemOverhead {
|
||||
size_t peak_allocated;
|
||||
size_t total_allocated;
|
||||
size_t startup_allocated;
|
||||
size_t repl_backlog;
|
||||
@ -781,6 +782,7 @@ struct redisMemOverhead {
|
||||
size_t overhead_total;
|
||||
size_t dataset;
|
||||
float dataset_perc;
|
||||
float peak_perc;
|
||||
size_t num_dbs;
|
||||
struct {
|
||||
size_t dbid;
|
||||
|
Loading…
x
Reference in New Issue
Block a user