Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
别团等shy哥发育
redis
提交
250e7f69
R
redis
项目概览
别团等shy哥发育
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
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,发现更多精彩内容 >>
提交
250e7f69
编写于
3月 08, 2012
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Instantaneous ops/sec figure in INFO output.
上级
0823e48f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
40 addition
and
0 deletion
+40
-0
src/redis.c
src/redis.c
+33
-0
src/redis.h
src/redis.h
+7
-0
未找到文件。
src/redis.c
浏览文件 @
250e7f69
...
...
@@ -616,6 +616,31 @@ void updateLRUClock(void) {
REDIS_LRU_CLOCK_MAX
;
}
/* Add a sample to the operations per second array of samples. */
void
trackOperationsPerSecond
(
void
)
{
long
long
t
=
mstime
()
-
server
.
ops_sec_last_sample_time
;
long
long
ops
=
server
.
stat_numcommands
-
server
.
ops_sec_last_sample_ops
;
long
long
ops_sec
;
ops_sec
=
t
>
0
?
(
ops
*
1000
/
t
)
:
0
;
server
.
ops_sec_samples
[
server
.
ops_sec_idx
]
=
ops_sec
;
server
.
ops_sec_idx
=
(
server
.
ops_sec_idx
+
1
)
%
REDIS_OPS_SEC_SAMPLES
;
server
.
ops_sec_last_sample_time
=
mstime
();
server
.
ops_sec_last_sample_ops
=
server
.
stat_numcommands
;
}
/* Return the mean of all the samples. */
long
long
getOperationsPerSecond
(
void
)
{
int
j
;
long
long
sum
=
0
;
for
(
j
=
0
;
j
<
REDIS_OPS_SEC_SAMPLES
;
j
++
)
sum
+=
server
.
ops_sec_samples
[
j
];
return
sum
/
REDIS_OPS_SEC_SAMPLES
;
}
int
serverCron
(
struct
aeEventLoop
*
eventLoop
,
long
long
id
,
void
*
clientData
)
{
int
j
,
loops
=
server
.
cronloops
;
REDIS_NOTUSED
(
eventLoop
);
...
...
@@ -628,6 +653,8 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
* To access a global var is faster than calling time(NULL) */
server
.
unixtime
=
time
(
NULL
);
trackOperationsPerSecond
();
/* We have just 22 bits per object for LRU information.
* So we use an (eventually wrapping) LRU clock with 10 seconds resolution.
* 2^22 bits with 10 seconds resoluton is more or less 1.5 years.
...
...
@@ -1091,6 +1118,10 @@ void initServer() {
server
.
stat_peak_memory
=
0
;
server
.
stat_fork_time
=
0
;
server
.
stat_rejected_conn
=
0
;
memset
(
server
.
ops_sec_samples
,
0
,
sizeof
(
server
.
ops_sec_samples
));
server
.
ops_sec_idx
=
0
;
server
.
ops_sec_last_sample_time
=
mstime
();
server
.
ops_sec_last_sample_ops
=
0
;
server
.
unixtime
=
time
(
NULL
);
server
.
lastbgsave_status
=
REDIS_OK
;
server
.
stop_writes_on_bgsave_err
=
1
;
...
...
@@ -1726,6 +1757,7 @@ sds genRedisInfoString(char *section) {
"# Stats
\r\n
"
"total_connections_received:%lld
\r\n
"
"total_commands_processed:%lld
\r\n
"
"instantaneous_ops_per_sec:%lld
\r\n
"
"rejected_connections:%lld
\r\n
"
"expired_keys:%lld
\r\n
"
"evicted_keys:%lld
\r\n
"
...
...
@@ -1736,6 +1768,7 @@ sds genRedisInfoString(char *section) {
"latest_fork_usec:%lld
\r\n
"
,
server
.
stat_numconnections
,
server
.
stat_numcommands
,
getOperationsPerSecond
(),
server
.
stat_rejected_conn
,
server
.
stat_expiredkeys
,
server
.
stat_evictedkeys
,
...
...
src/redis.h
浏览文件 @
250e7f69
...
...
@@ -59,6 +59,7 @@
#define REDIS_REPL_PING_SLAVE_PERIOD 10
#define REDIS_RUN_ID_SIZE 40
#define REDIS_OPS_SEC_SAMPLES 16
/* Protocol and I/O related defines */
#define REDIS_MAX_QUERYBUF_LEN (1024*1024*1024)
/* 1GB max query buffer. */
...
...
@@ -606,6 +607,12 @@ struct redisServer {
long
long
slowlog_entry_id
;
/* SLOWLOG current entry ID */
long
long
slowlog_log_slower_than
;
/* SLOWLOG time limit (to get logged) */
unsigned
long
slowlog_max_len
;
/* SLOWLOG max number of items logged */
/* The following two are used to track instantaneous "load" in terms
* of operations per second. */
long
long
ops_sec_last_sample_time
;
/* Timestamp of last sample (in ms) */
long
long
ops_sec_last_sample_ops
;
/* numcommands in last sample */
long
long
ops_sec_samples
[
REDIS_OPS_SEC_SAMPLES
];
int
ops_sec_idx
;
/* Configuration */
int
verbosity
;
/* Loglevel in redis.conf */
int
maxidletime
;
/* Client timeout in seconds */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录