Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Turbo码先生
redis
提交
78f35f8d
R
redis
项目概览
Turbo码先生
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
78f35f8d
编写于
9月 16, 2016
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Memory related subcommands of DEBUG moved to MEMORY.
上级
123891db
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
43 addition
and
41 deletion
+43
-41
src/debug.c
src/debug.c
+0
-36
src/object.c
src/object.c
+40
-3
src/redis-cli.c
src/redis-cli.c
+3
-2
未找到文件。
src/debug.c
浏览文件 @
78f35f8d
...
...
@@ -252,14 +252,6 @@ void computeDatasetDigest(unsigned char *final) {
}
}
#if defined(USE_JEMALLOC)
void
inputCatSds
(
void
*
result
,
const
char
*
str
)
{
/* result is actually a (sds *), so re-cast it here */
sds
*
info
=
(
sds
*
)
result
;
*
info
=
sdscat
(
*
info
,
str
);
}
#endif
void
debugCommand
(
client
*
c
)
{
if
(
c
->
argc
==
1
)
{
addReplyError
(
c
,
"You must specify a subcommand for DEBUG. Try DEBUG HELP for info."
);
...
...
@@ -303,10 +295,6 @@ void debugCommand(client *c) {
"structsize -- Return the size of different Redis core C structures."
);
blen
++
;
addReplyStatus
(
c
,
"htstats <dbid> -- Return hash table statistics of the specified Redis database."
);
blen
++
;
addReplyStatus
(
c
,
"jemalloc info -- Show internal jemalloc statistics."
);
blen
++
;
addReplyStatus
(
c
,
"jemalloc purge -- Force jemalloc to release unused memory."
);
setDeferredMultiBulkLength
(
c
,
blenp
,
blen
);
}
else
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"segfault"
))
{
*
((
char
*
)
-
1
)
=
'x'
;
...
...
@@ -520,30 +508,6 @@ void debugCommand(client *c) {
stats
=
sdscat
(
stats
,
buf
);
addReplyBulkSds
(
c
,
stats
);
}
else
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"jemalloc"
)
&&
c
->
argc
==
3
)
{
#if defined(USE_JEMALLOC)
if
(
!
strcasecmp
(
c
->
argv
[
2
]
->
ptr
,
"info"
))
{
sds
info
=
sdsempty
();
je_malloc_stats_print
(
inputCatSds
,
&
info
,
NULL
);
addReplyBulkSds
(
c
,
info
);
}
else
if
(
!
strcasecmp
(
c
->
argv
[
2
]
->
ptr
,
"purge"
))
{
char
tmp
[
32
];
unsigned
narenas
=
0
;
size_t
sz
=
sizeof
(
unsigned
);
if
(
!
je_mallctl
(
"arenas.narenas"
,
&
narenas
,
&
sz
,
NULL
,
0
))
{
sprintf
(
tmp
,
"arena.%d.purge"
,
narenas
);
if
(
!
je_mallctl
(
tmp
,
NULL
,
0
,
NULL
,
0
))
{
addReply
(
c
,
shared
.
ok
);
return
;
}
}
addReplyError
(
c
,
"Error purging dirty pages"
);
}
else
{
addReplyErrorFormat
(
c
,
"Valid jemalloc debug fields: info, purge"
);
}
#else
addReplyErrorFormat
(
c
,
"jemalloc support not available"
);
#endif
}
else
{
addReplyErrorFormat
(
c
,
"Unknown DEBUG subcommand or wrong number of arguments for '%s'"
,
(
char
*
)
c
->
argv
[
1
]
->
ptr
);
...
...
src/object.c
浏览文件 @
78f35f8d
...
...
@@ -893,6 +893,14 @@ struct redisMemOverhead *getMemoryOverheadData(void) {
return
mh
;
}
/* Helper for "MEMORY allocator-stats", used as a callback for the jemalloc
* stats output. */
void
inputCatSds
(
void
*
result
,
const
char
*
str
)
{
/* result is actually a (sds *), so re-cast it here */
sds
*
info
=
(
sds
*
)
result
;
*
info
=
sdscat
(
*
info
,
str
);
}
/* ======================= The OBJECT and MEMORY commands =================== */
/* This is a helper function for the OBJECT command. We need to lookup keys
...
...
@@ -1023,12 +1031,41 @@ void memoryCommand(client *c) {
addReplyDouble
(
c
,
mh
->
dataset_perc
);
freeMemoryOverheadData
(
mh
);
}
else
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"allocator-stats"
)
&&
c
->
argc
==
2
)
{
#if defined(USE_JEMALLOC)
sds
info
=
sdsempty
();
je_malloc_stats_print
(
inputCatSds
,
&
info
,
NULL
);
addReplyBulkSds
(
c
,
info
);
#else
addReplyBulkCString
(
c
,
"Stats not supported for the current allocator"
);
#endif
}
else
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"purge"
)
&&
c
->
argc
==
2
)
{
#if defined(USE_JEMALLOC)
char
tmp
[
32
];
unsigned
narenas
=
0
;
size_t
sz
=
sizeof
(
unsigned
);
if
(
!
je_mallctl
(
"arenas.narenas"
,
&
narenas
,
&
sz
,
NULL
,
0
))
{
sprintf
(
tmp
,
"arena.%d.purge"
,
narenas
);
if
(
!
je_mallctl
(
tmp
,
NULL
,
0
,
NULL
,
0
))
{
addReply
(
c
,
shared
.
ok
);
return
;
}
}
addReplyError
(
c
,
"Error purging dirty pages"
);
#else
addReply
(
c
,
shared
.
ok
);
/* Nothing to do for other allocators. */
#endif
}
else
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"help"
)
&&
c
->
argc
==
2
)
{
addReplyMultiBulkLen
(
c
,
2
);
addReplyMultiBulkLen
(
c
,
4
);
addReplyBulkCString
(
c
,
"MEMORY USAGE <key> [SAMPLES <count>] - Estimate memory usage of key"
);
addReplyBulkCString
(
c
,
"MEMORY OVERHEAD - Show memory usage details"
);
addReplyBulkCString
(
c
,
"MEMORY USAGE <key> [SAMPLES <count>] - Estimate memory usage of ke
y"
);
"MEMORY PURGE - Ask the allocator to release memor
y"
);
addReplyBulkCString
(
c
,
"MEMORY OVERHEAD - Show memory usage detail
s"
);
"MEMORY ALLOCATOR-STATS - Show allocator internal stat
s"
);
}
else
{
addReplyError
(
c
,
"Syntax error. Try MEMORY HELP"
);
}
...
...
src/redis-cli.c
浏览文件 @
78f35f8d
...
...
@@ -843,8 +843,9 @@ static int cliSendCommand(int argc, char **argv, int repeat) {
output_raw
=
0
;
if
(
!
strcasecmp
(
command
,
"info"
)
||
(
argc
>=
2
&&
!
strcasecmp
(
command
,
"debug"
)
&&
((
!
strcasecmp
(
argv
[
1
],
"jemalloc"
)
&&
!
strcasecmp
(
argv
[
2
],
"info"
))
||
!
strcasecmp
(
argv
[
1
],
"htstats"
)))
||
!
strcasecmp
(
argv
[
1
],
"htstats"
))
||
(
argc
>=
2
&&
!
strcasecmp
(
command
,
"memory"
)
&&
!
strcasecmp
(
argv
[
1
],
"allocator-stats"
))
||
(
argc
==
2
&&
!
strcasecmp
(
command
,
"cluster"
)
&&
(
!
strcasecmp
(
argv
[
1
],
"nodes"
)
||
!
strcasecmp
(
argv
[
1
],
"info"
)))
||
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录