Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
hanoi2005
redis
提交
98a9abb6
R
redis
项目概览
hanoi2005
/
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,发现更多精彩内容 >>
提交
98a9abb6
编写于
12月 30, 2010
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
don't use small shared integer objects when disk store is enabled
上级
82ef6ebf
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
17 addition
and
8 deletion
+17
-8
src/dscache.c
src/dscache.c
+13
-5
src/networking.c
src/networking.c
+1
-1
src/object.c
src/object.c
+2
-1
src/redis.h
src/redis.h
+1
-1
未找到文件。
src/dscache.c
浏览文件 @
98a9abb6
...
...
@@ -87,6 +87,8 @@
*
* - If dsSet() fails on the write thread log the error and reschedule the
* key for flush.
*
* - Check why INCR will not update the LRU info for the object.
*/
/* Virtual Memory is composed mainly of two subsystems:
...
...
@@ -133,6 +135,7 @@ void dsInit(void) {
server
.
io_processed
=
listCreate
();
server
.
io_ready_clients
=
listCreate
();
pthread_mutex_init
(
&
server
.
io_mutex
,
NULL
);
pthread_cond_init
(
&
server
.
io_condvar
,
NULL
);
server
.
io_active_threads
=
0
;
if
(
pipe
(
pipefds
)
==
-
1
)
{
redisLog
(
REDIS_WARNING
,
"Unable to intialized DS: pipe(2): %s. Exiting."
...
...
@@ -329,13 +332,14 @@ void *IOThreadEntryPoint(void *arg) {
REDIS_NOTUSED
(
arg
);
pthread_detach
(
pthread_self
());
lockThreadedIO
();
while
(
1
)
{
/* Wait for more work to do */
pthread_cond_wait
(
&
server
.
io_condvar
,
&
server
.
io_mutex
);
/* Get a new job to process */
lockThreadedIO
();
if
(
listLength
(
server
.
io_newjobs
)
==
0
)
{
/* No new jobs in queue,
exit
. */
/* No new jobs in queue,
reiterate
. */
unlockThreadedIO
();
sleep
(
1
);
continue
;
}
ln
=
listFirst
(
server
.
io_newjobs
);
...
...
@@ -345,6 +349,7 @@ void *IOThreadEntryPoint(void *arg) {
listAddNodeTail
(
server
.
io_processing
,
j
);
ln
=
listLast
(
server
.
io_processing
);
/* We use ln later to remove it */
unlockThreadedIO
();
redisLog
(
REDIS_DEBUG
,
"Thread %ld: new job type %s: %p about key '%s'"
,
(
long
)
pthread_self
(),
(
j
->
type
==
REDIS_IOJOB_LOAD
)
?
"load"
:
"save"
,
...
...
@@ -367,15 +372,17 @@ void *IOThreadEntryPoint(void *arg) {
/* Done: insert the job into the processed queue */
redisLog
(
REDIS_DEBUG
,
"Thread %ld completed the job: %p (key %s)"
,
(
long
)
pthread_self
(),
(
void
*
)
j
,
(
char
*
)
j
->
key
->
ptr
);
lockThreadedIO
();
listDelNode
(
server
.
io_processing
,
ln
);
listAddNodeTail
(
server
.
io_processed
,
j
);
unlockThreadedIO
();
/* Signal the main thread there is new stuff to process */
redisAssert
(
write
(
server
.
io_ready_pipe_write
,
"x"
,
1
)
==
1
);
}
return
NULL
;
/* never reached */
/* never reached, but that's the full pattern... */
unlockThreadedIO
();
return
NULL
;
}
void
spawnIOThread
(
void
)
{
...
...
@@ -449,6 +456,7 @@ void dsCreateIOJob(int type, redisDb *db, robj *key, robj *val) {
lockThreadedIO
();
queueIOJob
(
j
);
pthread_cond_signal
(
&
server
.
io_condvar
);
unlockThreadedIO
();
}
...
...
src/networking.c
浏览文件 @
98a9abb6
...
...
@@ -167,7 +167,7 @@ void _addReplyStringToList(redisClient *c, char *s, size_t len) {
void
addReply
(
redisClient
*
c
,
robj
*
obj
)
{
if
(
_installWriteEvent
(
c
)
!=
REDIS_OK
)
return
;
redisAssert
(
!
server
.
ds_enabled
||
obj
->
storage
==
REDIS_DS_MEMORY
);
redisAssert
(
!
server
.
ds_enabled
||
obj
->
storage
!=
REDIS_DS_SAVING
);
/* This is an important place where we can avoid copy-on-write
* when there is a saving child running, avoiding touching the
...
...
src/object.c
浏览文件 @
98a9abb6
...
...
@@ -32,6 +32,7 @@ robj *createStringObject(char *ptr, size_t len) {
robj
*
createStringObjectFromLongLong
(
long
long
value
)
{
robj
*
o
;
if
(
value
>=
0
&&
value
<
REDIS_SHARED_INTEGERS
&&
!
server
.
ds_enabled
&&
pthread_equal
(
pthread_self
(),
server
.
mainthread
))
{
incrRefCount
(
shared
.
integers
[
value
]);
o
=
shared
.
integers
[
value
];
...
...
@@ -214,7 +215,7 @@ robj *tryObjectEncoding(robj *o) {
* Note that we also avoid using shared integers when maxmemory is used
* because every object needs to have a private LRU field for the LRU
* algorithm to work well. */
if
(
server
.
ds_enabled
==
0
&&
if
(
!
server
.
ds_enabled
&&
server
.
maxmemory
==
0
&&
value
>=
0
&&
value
<
REDIS_SHARED_INTEGERS
&&
pthread_equal
(
pthread_self
(),
server
.
mainthread
))
{
...
...
src/redis.h
浏览文件 @
98a9abb6
...
...
@@ -459,7 +459,7 @@ struct redisServer {
list
*
io_processed
;
/* List of VM I/O jobs already processed */
list
*
io_ready_clients
;
/* Clients ready to be unblocked. All keys loaded */
pthread_mutex_t
io_mutex
;
/* lock to access io_jobs/io_done/io_thread_job */
pthread_
mutex_t
io_swapfile_mutex
;
/* So we can lseek + writ
e */
pthread_
cond_t
io_condvar
;
/* I/O threads conditional variabl
e */
pthread_attr_t
io_threads_attr
;
/* attributes for threads creation */
int
io_active_threads
;
/* Number of running I/O threads */
int
vm_max_threads
;
/* Max number of I/O threads running at the same time */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录