Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
d9325ac6
Commit
d9325ac6
authored
Sep 16, 2016
by
antirez
Browse files
Provide percentage of memory peak used info.
parent
309c2bcd
Changes
3
Show whitespace changes
Inline
Side-by-side
src/object.c
View file @
d9325ac6
...
@@ -810,6 +810,7 @@ struct redisMemOverhead *getMemoryOverheadData(void) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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) {
...
@@ -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)
...
...
src/server.c
View file @
d9325ac6
...
@@ -2837,6 +2837,7 @@ sds genRedisInfoString(char *section) {
...
@@ -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) {
...
@@ -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
,
...
...
src/server.h
View file @
d9325ac6
...
@@ -772,6 +772,7 @@ typedef struct redisOpArray {
...
@@ -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 {
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment