Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
9814b2a5
Commit
9814b2a5
authored
Mar 27, 2019
by
antirez
Browse files
Threaded IO: make num of I/O threads configurable.
parent
30091dc2
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/config.c
View file @
9814b2a5
...
...
@@ -313,6 +313,11 @@ void loadServerConfigFromString(char *config) {
if
(
server
.
dbnum
<
1
)
{
err
=
"Invalid number of databases"
;
goto
loaderr
;
}
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"io-threads"
)
&&
argc
==
2
)
{
server
.
io_threads_num
=
atoi
(
argv
[
1
]);
if
(
server
.
io_threads_num
<
1
||
server
.
io_threads_num
>
512
)
{
err
=
"Invalid number of I/O threads"
;
goto
loaderr
;
}
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"include"
)
&&
argc
==
2
)
{
loadServerConfig
(
argv
[
1
],
NULL
);
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"maxclients"
)
&&
argc
==
2
)
{
...
...
@@ -1426,6 +1431,7 @@ void configGetCommand(client *c) {
config_get_numerical_field
(
"cluster-announce-bus-port"
,
server
.
cluster_announce_bus_port
);
config_get_numerical_field
(
"tcp-backlog"
,
server
.
tcp_backlog
);
config_get_numerical_field
(
"databases"
,
server
.
dbnum
);
config_get_numerical_field
(
"io-threads"
,
server
.
io_threads_num
);
config_get_numerical_field
(
"repl-ping-slave-period"
,
server
.
repl_ping_slave_period
);
config_get_numerical_field
(
"repl-ping-replica-period"
,
server
.
repl_ping_slave_period
);
config_get_numerical_field
(
"repl-timeout"
,
server
.
repl_timeout
);
...
...
@@ -2239,6 +2245,7 @@ int rewriteConfig(char *path) {
rewriteConfigSaveOption
(
state
);
rewriteConfigUserOption
(
state
);
rewriteConfigNumericalOption
(
state
,
"databases"
,
server
.
dbnum
,
CONFIG_DEFAULT_DBNUM
);
rewriteConfigNumericalOption
(
state
,
"io-threads"
,
server
.
dbnum
,
CONFIG_DEFAULT_IO_THREADS_NUM
);
rewriteConfigYesNoOption
(
state
,
"stop-writes-on-bgsave-error"
,
server
.
stop_writes_on_bgsave_err
,
CONFIG_DEFAULT_STOP_WRITES_ON_BGSAVE_ERROR
);
rewriteConfigYesNoOption
(
state
,
"rdbcompression"
,
server
.
rdb_compression
,
CONFIG_DEFAULT_RDB_COMPRESSION
);
rewriteConfigYesNoOption
(
state
,
"rdbchecksum"
,
server
.
rdb_checksum
,
CONFIG_DEFAULT_RDB_CHECKSUM
);
...
...
src/networking.c
View file @
9814b2a5
...
...
@@ -2525,7 +2525,6 @@ void *IOThreadMain(void *myid) {
/* Initialize the data structures needed for threaded I/O. */
void
initThreadedIO
(
void
)
{
server
.
io_threads_num
=
8
;
io_threads_active
=
0
;
/* We start with threads not active. */
/* Don't spawn any thread if the user selected a single thread:
...
...
@@ -2576,7 +2575,7 @@ int stopThreadedIOIfNeeded(void) {
int
pending
=
listLength
(
server
.
clients_pending_write
);
/* Return ASAP if IO threads are disabled (single threaded mode). */
if
(
server
.
io_threads_num
==
1
)
return
0
;
if
(
server
.
io_threads_num
==
1
)
return
1
;
if
(
pending
<
(
server
.
io_threads_num
*
2
))
{
if
(
io_threads_active
)
stopThreadedIO
();
...
...
src/server.c
View file @
9814b2a5
...
...
@@ -2317,6 +2317,7 @@ void initServerConfig(void) {
server
.
lazyfree_lazy_server_del
=
CONFIG_DEFAULT_LAZYFREE_LAZY_SERVER_DEL
;
server
.
always_show_logo
=
CONFIG_DEFAULT_ALWAYS_SHOW_LOGO
;
server
.
lua_time_limit
=
LUA_SCRIPT_TIME_LIMIT
;
server
.
io_threads_num
=
CONFIG_DEFAULT_IO_THREADS_NUM
;
unsigned
int
lruclock
=
getLRUClock
();
atomicSet
(
server
.
lruclock
,
lruclock
);
...
...
src/server.h
View file @
9814b2a5
...
...
@@ -87,6 +87,7 @@ typedef long long mstime_t; /* millisecond time type. */
#define CONFIG_DEFAULT_TCP_BACKLOG 511
/* TCP listen backlog. */
#define CONFIG_DEFAULT_CLIENT_TIMEOUT 0
/* Default client timeout: infinite */
#define CONFIG_DEFAULT_DBNUM 16
#define CONFIG_DEFAULT_IO_THREADS_NUM 1
/* Single threaded by default */
#define CONFIG_MAX_LINE 1024
#define CRON_DBS_PER_CALL 16
#define NET_MAX_WRITES_PER_EVENT (1024*64)
...
...
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