Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
bcaa7a4f
Commit
bcaa7a4f
authored
Jan 14, 2010
by
antirez
Browse files
Set the new threads stack size to a LZF friendly amount
parent
427a2153
Changes
1
Show whitespace changes
Inline
Side-by-side
redis.c
View file @
bcaa7a4f
...
...
@@ -164,6 +164,7 @@
#define REDIS_VM_MAX_NEAR_PAGES 65536
#define REDIS_VM_MAX_RANDOM_JUMP 4096
#define REDIS_VM_MAX_THREADS 32
#define REDIS_THREAD_STACK_SIZE (1024*1024*4)
/* The following is the number of completed I/O jobs to process when the
* handelr is called. 1 is the minimum, and also the default, as it allows
* to block as little as possible other accessing clients. While Virtual
...
...
@@ -403,6 +404,7 @@ struct redisServer {
pthread_mutex_t
io_mutex
;
/* lock to access io_jobs/io_done/io_thread_job */
pthread_mutex_t
obj_freelist_mutex
;
/* safe redis objects creation/free */
pthread_mutex_t
io_swapfile_mutex
;
/* So we can lseek + write */
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 */
/* Our main thread is blocked on the event loop, locking for sockets ready
...
...
@@ -6984,6 +6986,7 @@ static void aofRemoveTempFile(pid_t childpid) {
static
void
vmInit
(
void
)
{
off_t
totsize
;
int
pipefds
[
2
];
size_t
stacksize
;
server
.
vm_fp
=
fopen
(
"/tmp/redisvm"
,
"w+b"
);
if
(
server
.
vm_fp
==
NULL
)
{
...
...
@@ -7031,6 +7034,11 @@ static void vmInit(void) {
server
.
io_ready_pipe_read
=
pipefds
[
0
];
server
.
io_ready_pipe_write
=
pipefds
[
1
];
redisAssert
(
anetNonBlock
(
NULL
,
server
.
io_ready_pipe_read
)
!=
ANET_ERR
);
/* LZF requires a lot of stack */
pthread_attr_init
(
&
server
.
io_threads_attr
);
pthread_attr_getstacksize
(
&
server
.
io_threads_attr
,
&
stacksize
);
while
(
stacksize
<
REDIS_THREAD_STACK_SIZE
)
stacksize
*=
2
;
pthread_attr_setstacksize
(
&
server
.
io_threads_attr
,
stacksize
);
/* Listen for events in the threaded I/O pipe */
if
(
aeCreateFileEvent
(
server
.
el
,
server
.
io_ready_pipe_read
,
AE_READABLE
,
vmThreadedIOCompletedJob
,
NULL
)
==
AE_ERR
)
...
...
@@ -7668,7 +7676,7 @@ static void *IOThreadEntryPoint(void *arg) {
static
void
spawnIOThread
(
void
)
{
pthread_t
thread
;
pthread_create
(
&
thread
,
NULL
,
IOThreadEntryPoint
,
NULL
);
pthread_create
(
&
thread
,
&
server
.
io_threads_attr
,
IOThreadEntryPoint
,
NULL
);
server
.
io_active_threads
++
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment