Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xindoo
redis
提交
c28b42ac
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,发现更多精彩内容 >>
提交
c28b42ac
编写于
11月 18, 2009
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more experiments with long replies, glue output buffer, and writev.
上级
cc30e368
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
25 addition
and
20 deletion
+25
-20
benchmark.c
benchmark.c
+4
-0
redis.c
redis.c
+17
-20
test-redis.tcl
test-redis.tcl
+4
-0
未找到文件。
benchmark.c
浏览文件 @
c28b42ac
...
...
@@ -486,6 +486,7 @@ int main(int argc, char **argv) {
}
do
{
#if 0
prepareForBenchmark();
c = createClient();
if (!c) exit(1);
...
...
@@ -547,6 +548,7 @@ int main(int argc, char **argv) {
aeMain(config.el);
endBenchmark("PING");
#endif
prepareForBenchmark
();
c
=
createClient
();
if
(
!
c
)
exit
(
1
);
...
...
@@ -556,6 +558,7 @@ int main(int argc, char **argv) {
aeMain
(
config
.
el
);
endBenchmark
(
"LPUSH (again, in order to bench LRANGE)"
);
#if 0
prepareForBenchmark();
c = createClient();
if (!c) exit(1);
...
...
@@ -582,6 +585,7 @@ int main(int argc, char **argv) {
createMissingClients(c);
aeMain(config.el);
endBenchmark("LRANGE (first 450 elements)");
#endif
prepareForBenchmark
();
c
=
createClient
();
...
...
redis.c
浏览文件 @
c28b42ac
...
...
@@ -1351,33 +1351,29 @@ static void freeClient(redisClient *c) {
#define GLUEREPLY_UP_TO (1024)
static
void
glueReplyBuffersIfNeeded
(
redisClient
*
c
)
{
int
totlen
=
0
;
int
copylen
=
0
;
char
buf
[
GLUEREPLY_UP_TO
];
listNode
*
ln
;
robj
*
o
;
listRewind
(
c
->
reply
);
while
((
ln
=
listYield
(
c
->
reply
)))
{
int
objlen
;
o
=
ln
->
value
;
totlen
+=
sdslen
(
o
->
ptr
);
/* This optimization makes more sense if we don't have to copy
* too much data */
if
(
totlen
>
GLUEREPLY_UP_TO
)
return
;
}
if
(
totlen
>
0
)
{
char
buf
[
GLUEREPLY_UP_TO
];
int
copylen
=
0
;
listRewind
(
c
->
reply
);
while
((
ln
=
listYield
(
c
->
reply
)))
{
o
=
ln
->
value
;
memcpy
(
buf
+
copylen
,
o
->
ptr
,
sdslen
(
o
->
ptr
));
copylen
+=
sdslen
(
o
->
ptr
);
objlen
=
sdslen
(
o
->
ptr
);
if
(
copylen
+
objlen
<=
GLUEREPLY_UP_TO
)
{
memcpy
(
buf
+
copylen
,
o
->
ptr
,
objlen
);
copylen
+=
objlen
;
listDelNode
(
c
->
reply
,
ln
);
}
else
{
if
(
copylen
==
0
)
return
;
break
;
}
/* Now the output buffer is empty, add the new single element */
o
=
createObject
(
REDIS_STRING
,
sdsnewlen
(
buf
,
totlen
));
listAddNodeTail
(
c
->
reply
,
o
);
}
/* Now the output buffer is empty, add the new single element */
o
=
createObject
(
REDIS_STRING
,
sdsnewlen
(
buf
,
copylen
));
listAddNodeHead
(
c
->
reply
,
o
);
}
static
void
sendReplyToClient
(
aeEventLoop
*
el
,
int
fd
,
void
*
privdata
,
int
mask
)
{
...
...
@@ -1387,8 +1383,6 @@ static void sendReplyToClient(aeEventLoop *el, int fd, void *privdata, int mask)
REDIS_NOTUSED
(
el
);
REDIS_NOTUSED
(
mask
);
if
(
server
.
glueoutputbuf
&&
listLength
(
c
->
reply
)
>
1
)
glueReplyBuffersIfNeeded
(
c
);
/* Use writev() if we have enough buffers to send */
#if 0
...
...
@@ -1401,6 +1395,9 @@ static void sendReplyToClient(aeEventLoop *el, int fd, void *privdata, int mask)
#endif
while
(
listLength
(
c
->
reply
))
{
if
(
server
.
glueoutputbuf
&&
listLength
(
c
->
reply
)
>
1
)
glueReplyBuffersIfNeeded
(
c
);
o
=
listNodeValue
(
listFirst
(
c
->
reply
));
objlen
=
sdslen
(
o
->
ptr
);
...
...
test-redis.tcl
浏览文件 @
c28b42ac
...
...
@@ -912,6 +912,10 @@ proc main {server port} {
lappend aux
[
$r
dbsize
]
}
{
0 0
}
test
{
Perform a final SAVE to leave a clean DB on disk
}
{
$r save
}
{
OK
}
puts
"
\n
[
expr $::passed+$::failed
]
tests,
$::passed
passed,
$::failed
failed"
if
{
$::failed
> 0
}
{
puts
"
\n
*** WARNING!!!
$::failed
FAILED TESTS ***
\n
"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录