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
e9629e14
Commit
e9629e14
authored
Sep 15, 2016
by
antirez
Browse files
MEMORY command: HELP + dataset percentage (like in INFO).
parent
5443726d
Changes
3
Show whitespace changes
Inline
Side-by-side
src/object.c
View file @
e9629e14
...
@@ -936,6 +936,12 @@ struct redisMemOverhead *getMemoryOverheadData(void) {
...
@@ -936,6 +936,12 @@ struct redisMemOverhead *getMemoryOverheadData(void) {
mh
->
overhead_total
=
mem_total
;
mh
->
overhead_total
=
mem_total
;
mh
->
dataset
=
zmalloc_used
-
mem_total
;
mh
->
dataset
=
zmalloc_used
-
mem_total
;
size_t
net_usage
=
1
;
if
(
zmalloc_used
>
mh
->
startup_allocated
)
net_usage
=
zmalloc_used
-
mh
->
startup_allocated
;
mh
->
dataset_perc
=
(
float
)
mh
->
dataset
*
100
/
net_usage
;
return
mh
;
return
mh
;
}
}
...
@@ -974,7 +980,7 @@ void memoryCommand(client *c) {
...
@@ -974,7 +980,7 @@ 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
,(
8
+
mh
->
num_dbs
)
*
2
);
addReplyMultiBulkLen
(
c
,(
9
+
mh
->
num_dbs
)
*
2
);
addReplyBulkCString
(
c
,
"total.allocated"
);
addReplyBulkCString
(
c
,
"total.allocated"
);
addReplyLongLong
(
c
,
mh
->
total_allocated
);
addReplyLongLong
(
c
,
mh
->
total_allocated
);
...
@@ -1010,11 +1016,20 @@ void memoryCommand(client *c) {
...
@@ -1010,11 +1016,20 @@ void memoryCommand(client *c) {
addReplyBulkCString
(
c
,
"overhead.total"
);
addReplyBulkCString
(
c
,
"overhead.total"
);
addReplyLongLong
(
c
,
mh
->
overhead_total
);
addReplyLongLong
(
c
,
mh
->
overhead_total
);
addReplyBulkCString
(
c
,
"dataset"
);
addReplyBulkCString
(
c
,
"dataset
.bytes
"
);
addReplyLongLong
(
c
,
mh
->
dataset
);
addReplyLongLong
(
c
,
mh
->
dataset
);
addReplyBulkCString
(
c
,
"dataset.percentage"
);
addReplyDouble
(
c
,
mh
->
dataset_perc
);
freeMemoryOverheadData
(
mh
);
freeMemoryOverheadData
(
mh
);
}
else
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"help"
)
&&
c
->
argc
==
2
)
{
addReplyMultiBulkLen
(
c
,
2
);
addReplyBulkCString
(
c
,
"MEMORY USAGE <key> [SAMPLES <count>] - Estimate memory usage of key"
);
addReplyBulkCString
(
c
,
"MEMORY OVERHEAD - Show memory usage details"
);
}
else
{
}
else
{
addReplyError
(
c
,
"Syntax error. Try MEMORY
[usage <key>] | [overhead]
"
);
addReplyError
(
c
,
"Syntax error. Try MEMORY
HELP
"
);
}
}
}
}
src/server.c
View file @
e9629e14
...
@@ -2828,10 +2828,6 @@ sds genRedisInfoString(char *section) {
...
@@ -2828,10 +2828,6 @@ sds genRedisInfoString(char *section) {
bytesToHuman
(
used_memory_rss_hmem
,
server
.
resident_set_size
);
bytesToHuman
(
used_memory_rss_hmem
,
server
.
resident_set_size
);
bytesToHuman
(
maxmemory_hmem
,
server
.
maxmemory
);
bytesToHuman
(
maxmemory_hmem
,
server
.
maxmemory
);
size_t
net_usage
=
1
;
if
(
zmalloc_used
>
mh
->
startup_allocated
)
net_usage
=
zmalloc_used
-
mh
->
startup_allocated
;
if
(
sections
++
)
info
=
sdscat
(
info
,
"
\r\n
"
);
if
(
sections
++
)
info
=
sdscat
(
info
,
"
\r\n
"
);
info
=
sdscatprintf
(
info
,
info
=
sdscatprintf
(
info
,
"# Memory
\r\n
"
"# Memory
\r\n
"
...
@@ -2864,7 +2860,7 @@ sds genRedisInfoString(char *section) {
...
@@ -2864,7 +2860,7 @@ sds genRedisInfoString(char *section) {
mh
->
overhead_total
,
mh
->
overhead_total
,
mh
->
startup_allocated
,
mh
->
startup_allocated
,
mh
->
dataset
,
mh
->
dataset
,
(
float
)
mh
->
dataset
*
100
/
net_usage
,
mh
->
dataset
_perc
,
(
unsigned
long
)
total_system_mem
,
(
unsigned
long
)
total_system_mem
,
total_system_hmem
,
total_system_hmem
,
memory_lua
,
memory_lua
,
...
...
src/server.h
View file @
e9629e14
...
@@ -780,6 +780,7 @@ struct redisMemOverhead {
...
@@ -780,6 +780,7 @@ struct redisMemOverhead {
size_t
aof_buffer
;
size_t
aof_buffer
;
size_t
overhead_total
;
size_t
overhead_total
;
size_t
dataset
;
size_t
dataset
;
float
dataset_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