Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xindoo
redis
提交
7d98e08c
R
redis
项目概览
xindoo
/
redis
通知
2
Star
2
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,体验更适合开发者的 AI 搜索 >>
提交
7d98e08c
编写于
1月 06, 2010
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
VM stats in INFO command
上级
f870935d
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
39 addition
and
2 deletion
+39
-2
redis.c
redis.c
+36
-0
redis.conf
redis.conf
+3
-2
未找到文件。
redis.c
浏览文件 @
7d98e08c
...
...
@@ -381,6 +381,11 @@ struct redisServer {
off_t
vm_near_pages
;
/* Number of pages allocated sequentially */
unsigned
char
*
vm_bitmap
;
/* Bitmap of free/used pages */
time_t
unixtime
;
/* Unix time sampled every second. */
/* Virtual memory stats */
unsigned
long
long
vm_stats_used_pages
;
unsigned
long
long
vm_stats_swapped_objects
;
unsigned
long
long
vm_stats_swapouts
;
unsigned
long
long
vm_stats_swapins
;
};
typedef
void
redisCommandProc
(
redisClient
*
c
);
...
...
@@ -2382,6 +2387,7 @@ static void decrRefCount(void *obj) {
if
(
listLength
(
server
.
objfreelist
)
>
REDIS_OBJFREELIST_MAX
||
!
listAddNodeHead
(
server
.
objfreelist
,
o
))
zfree
(
o
);
server
.
vm_stats_swapped_objects
--
;
return
;
}
/* REDIS_VM_MEMORY */
...
...
@@ -5417,6 +5423,7 @@ static sds genRedisInfoString(void) {
"bgrewriteaof_in_progress:%d
\r\n
"
"total_connections_received:%lld
\r\n
"
"total_commands_processed:%lld
\r\n
"
"vm_enabled:%d
\r\n
"
"role:%s
\r\n
"
,
REDIS_VERSION
,
(
sizeof
(
long
)
==
8
)
?
"64"
:
"32"
,
...
...
@@ -5433,6 +5440,7 @@ static sds genRedisInfoString(void) {
server
.
bgrewritechildpid
!=
-
1
,
server
.
stat_numconnections
,
server
.
stat_numcommands
,
server
.
vm_enabled
!=
0
,
server
.
masterhost
==
NULL
?
"master"
:
"slave"
);
if
(
server
.
masterhost
)
{
...
...
@@ -5448,6 +5456,24 @@ static sds genRedisInfoString(void) {
server
.
master
?
((
int
)(
time
(
NULL
)
-
server
.
master
->
lastinteraction
))
:
-
1
);
}
if
(
server
.
vm_enabled
)
{
info
=
sdscatprintf
(
info
,
"vm_conf_max_memory:%llu
\r\n
"
"vm_conf_page_size:%llu
\r\n
"
"vm_conf_pages:%llu
\r\n
"
"vm_stats_used_pages:%llu
\r\n
"
"vm_stats_swapped_objects:%llu
\r\n
"
"vm_stats_swappin_count:%llu
\r\n
"
"vm_stats_swappout_count:%llu
\r\n
"
,(
unsigned
long
long
)
server
.
vm_max_memory
,
(
unsigned
long
long
)
server
.
vm_page_size
,
(
unsigned
long
long
)
server
.
vm_pages
,
(
unsigned
long
long
)
server
.
vm_stats_used_pages
,
(
unsigned
long
long
)
server
.
vm_stats_swapped_objects
,
(
unsigned
long
long
)
server
.
vm_stats_swapins
,
(
unsigned
long
long
)
server
.
vm_stats_swapouts
);
}
for
(
j
=
0
;
j
<
server
.
dbnum
;
j
++
)
{
long
long
keys
,
vkeys
;
...
...
@@ -6734,6 +6760,10 @@ static void vmInit(void) {
server
.
vm_fd
=
fileno
(
server
.
vm_fp
);
server
.
vm_next_page
=
0
;
server
.
vm_near_pages
=
0
;
server
.
vm_stats_used_pages
=
0
;
server
.
vm_stats_swapped_objects
=
0
;
server
.
vm_stats_swapouts
=
0
;
server
.
vm_stats_swapins
=
0
;
totsize
=
server
.
vm_pages
*
server
.
vm_page_size
;
redisLog
(
REDIS_NOTICE
,
"Allocating %lld bytes of swap file"
,
totsize
);
if
(
ftruncate
(
server
.
vm_fd
,
totsize
)
==
-
1
)
{
...
...
@@ -6767,6 +6797,7 @@ static void vmMarkPagesUsed(off_t page, off_t count) {
for
(
j
=
0
;
j
<
count
;
j
++
)
vmMarkPageUsed
(
page
+
j
);
server
.
vm_stats_used_pages
+=
count
;
}
/* Mark the page as free */
...
...
@@ -6782,6 +6813,7 @@ static void vmMarkPagesFree(off_t page, off_t count) {
for
(
j
=
0
;
j
<
count
;
j
++
)
vmMarkPageFree
(
page
+
j
);
server
.
vm_stats_used_pages
-=
count
;
}
/* Test if the page is free */
...
...
@@ -6891,6 +6923,8 @@ static int vmSwapObject(robj *key, robj *val) {
redisLog
(
REDIS_DEBUG
,
"VM: object %s swapped out at %lld (%lld pages)"
,
(
unsigned
char
*
)
key
->
ptr
,
(
unsigned
long
long
)
page
,
(
unsigned
long
long
)
pages
);
server
.
vm_stats_swapped_objects
++
;
server
.
vm_stats_swapouts
++
;
return
REDIS_OK
;
}
...
...
@@ -6920,7 +6954,9 @@ static robj *vmGenericLoadObject(robj *key, int preview) {
vmMarkPagesFree
(
key
->
vm
.
page
,
key
->
vm
.
usedpages
);
redisLog
(
REDIS_DEBUG
,
"VM: object %s loaded from disk"
,
(
unsigned
char
*
)
key
->
ptr
);
server
.
vm_stats_swapped_objects
--
;
}
server
.
vm_stats_swapins
++
;
return
val
;
}
...
...
redis.conf
浏览文件 @
7d98e08c
...
...
@@ -24,7 +24,7 @@ timeout 300
# debug (a lot of information, useful for development/testing)
# notice (moderately verbose, what you want in production probably)
# warning (only very important / critical messages are logged)
loglevel
verbose
loglevel
debug
# Specify the log file name. Also 'stdout' can be used to force
# the demon to log on the standard output. Note that if you use standard
...
...
@@ -205,7 +205,8 @@ vm-page-size 256
#
# With the default of 256-bytes memory pages and 104857600 pages Redis will
# use a 25 GB swap file, that will use rougly 13 MB of RAM for the page table.
vm
-
pages
104857600
# vm-pages 104857600
vm
-
pages
1000000
############################### ADVANCED CONFIG ###############################
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录