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