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
a330d06c
Commit
a330d06c
authored
Jul 30, 2018
by
antirez
Browse files
Control dynamic HZ via server configuration.
parent
d42602ff
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/server.c
View file @
a330d06c
...
@@ -1096,14 +1096,18 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
...
@@ -1096,14 +1096,18 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
/* Update the time cache. */
/* Update the time cache. */
updateCachedTime
();
updateCachedTime
();
server
.
hz
=
server
.
config_hz
;
/* Adapt the server.hz value to the number of configured clients. If we have
/* Adapt the server.hz value to the number of configured clients. If we have
* many clients, we want to call serverCron() with an higher frequency. */
* many clients, we want to call serverCron() with an higher frequency. */
server
.
hz
=
server
.
config_hz
;
if
(
server
.
dynamic_hz
)
{
while
(
listLength
(
server
.
clients
)
/
server
.
hz
>
MAX_CLIENTS_PER_CLOCK_TICK
)
{
while
(
listLength
(
server
.
clients
)
/
server
.
hz
>
server
.
hz
*=
2
;
MAX_CLIENTS_PER_CLOCK_TICK
)
if
(
server
.
hz
>
CONFIG_MAX_HZ
)
{
{
server
.
hz
=
CONFIG_MAX_HZ
;
server
.
hz
*=
2
;
break
;
if
(
server
.
hz
>
CONFIG_MAX_HZ
)
{
server
.
hz
=
CONFIG_MAX_HZ
;
break
;
}
}
}
}
}
...
@@ -1524,6 +1528,7 @@ void initServerConfig(void) {
...
@@ -1524,6 +1528,7 @@ void initServerConfig(void) {
server
.
configfile
=
NULL
;
server
.
configfile
=
NULL
;
server
.
executable
=
NULL
;
server
.
executable
=
NULL
;
server
.
config_hz
=
CONFIG_DEFAULT_HZ
;
server
.
config_hz
=
CONFIG_DEFAULT_HZ
;
server
.
dynamic_hz
=
CONFIG_DEFAULT_DYNAMIC_HZ
;
server
.
arch_bits
=
(
sizeof
(
long
)
==
8
)
?
64
:
32
;
server
.
arch_bits
=
(
sizeof
(
long
)
==
8
)
?
64
:
32
;
server
.
port
=
CONFIG_DEFAULT_SERVER_PORT
;
server
.
port
=
CONFIG_DEFAULT_SERVER_PORT
;
server
.
tcp_backlog
=
CONFIG_DEFAULT_TCP_BACKLOG
;
server
.
tcp_backlog
=
CONFIG_DEFAULT_TCP_BACKLOG
;
...
...
src/server.h
View file @
a330d06c
...
@@ -78,6 +78,7 @@ typedef long long mstime_t; /* millisecond time type. */
...
@@ -78,6 +78,7 @@ typedef long long mstime_t; /* millisecond time type. */
#define C_ERR -1
#define C_ERR -1
/* Static server configuration */
/* Static server configuration */
#define CONFIG_DEFAULT_DYNAMIC_HZ 1
/* Adapt hz to # of clients.*/
#define CONFIG_DEFAULT_HZ 10
/* Time interrupt calls/sec. */
#define CONFIG_DEFAULT_HZ 10
/* Time interrupt calls/sec. */
#define CONFIG_MIN_HZ 1
#define CONFIG_MIN_HZ 1
#define CONFIG_MAX_HZ 500
#define CONFIG_MAX_HZ 500
...
@@ -925,6 +926,7 @@ struct redisServer {
...
@@ -925,6 +926,7 @@ struct redisServer {
char
*
configfile
;
/* Absolute config file path, or NULL */
char
*
configfile
;
/* Absolute config file path, or NULL */
char
*
executable
;
/* Absolute executable file path. */
char
*
executable
;
/* Absolute executable file path. */
char
**
exec_argv
;
/* Executable argv vector (copy). */
char
**
exec_argv
;
/* Executable argv vector (copy). */
int
dynamic_hz
;
/* Change hz value depending on # of clients. */
int
config_hz
;
/* Configured HZ value. May be different than
int
config_hz
;
/* Configured HZ value. May be different than
the actual 'hz' field value if dynamic-hz
the actual 'hz' field value if dynamic-hz
is enabled. */
is enabled. */
...
...
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