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
b65ddfb1
Commit
b65ddfb1
authored
Jul 23, 2018
by
antirez
Browse files
Dynamic HZ: adapt cron frequency to number of clients.
parent
e6ea603a
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/server.c
View file @
b65ddfb1
...
@@ -1096,6 +1096,17 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
...
@@ -1096,6 +1096,17 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
/* Update the time cache. */
/* Update the time cache. */
updateCachedTime
();
updateCachedTime
();
/* 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. */
server
.
hz
=
server
.
config_hz
;
while
(
listLength
(
server
.
clients
)
/
server
.
hz
>
MAX_CLIENTS_PER_CLOCK_TICK
)
{
server
.
hz
*=
2
;
if
(
server
.
hz
>
CONFIG_MAX_HZ
)
{
server
.
hz
=
CONFIG_MAX_HZ
;
break
;
}
}
run_with_period
(
100
)
{
run_with_period
(
100
)
{
trackInstantaneousMetric
(
STATS_METRIC_COMMAND
,
server
.
stat_numcommands
);
trackInstantaneousMetric
(
STATS_METRIC_COMMAND
,
server
.
stat_numcommands
);
trackInstantaneousMetric
(
STATS_METRIC_NET_INPUT
,
trackInstantaneousMetric
(
STATS_METRIC_NET_INPUT
,
...
...
src/server.h
View file @
b65ddfb1
...
@@ -78,12 +78,13 @@ typedef long long mstime_t; /* millisecond time type. */
...
@@ -78,12 +78,13 @@ 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_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
#define CONFIG_DEFAULT_SERVER_PORT 6379
/* TCP port */
#define MAX_CLIENTS_PER_CLOCK_TICK 200
/* HZ is adapted based on that. */
#define CONFIG_DEFAULT_TCP_BACKLOG 511
/* TCP listen backlog */
#define CONFIG_DEFAULT_SERVER_PORT 6379
/* TCP port. */
#define CONFIG_DEFAULT_CLIENT_TIMEOUT 0
/* default client timeout: infinite */
#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_DBNUM 16
#define CONFIG_MAX_LINE 1024
#define CONFIG_MAX_LINE 1024
#define CRON_DBS_PER_CALL 16
#define CRON_DBS_PER_CALL 16
...
@@ -91,7 +92,7 @@ typedef long long mstime_t; /* millisecond time type. */
...
@@ -91,7 +92,7 @@ typedef long long mstime_t; /* millisecond time type. */
#define PROTO_SHARED_SELECT_CMDS 10
#define PROTO_SHARED_SELECT_CMDS 10
#define OBJ_SHARED_INTEGERS 10000
#define OBJ_SHARED_INTEGERS 10000
#define OBJ_SHARED_BULKHDR_LEN 32
#define OBJ_SHARED_BULKHDR_LEN 32
#define LOG_MAX_LEN 1024
/* Default maximum length of syslog messages
*/
#define LOG_MAX_LEN 1024
/* Default maximum length of syslog messages
.
*/
#define AOF_REWRITE_PERC 100
#define AOF_REWRITE_PERC 100
#define AOF_REWRITE_MIN_SIZE (64*1024*1024)
#define AOF_REWRITE_MIN_SIZE (64*1024*1024)
#define AOF_REWRITE_ITEMS_PER_CMD 64
#define AOF_REWRITE_ITEMS_PER_CMD 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