mirror of
https://github.com/fluencelabs/redis
synced 2025-05-01 05:22:13 +00:00
A way to disable time accounting in call().
This commit allows to avoid two mstime() calls inside the call() function, when the following conditions are true: 1. slowlog is disabled. 2. latency monitoring is disabled. 3. command time acconuting is disabled. Note that '3' was not configurable, this patch just disable it without really allowing the user to turn it on, since this is currently an experiment. If the commit will be merged into unstable, proper support to configure this parameter will be added. Related to issue #2552.
This commit is contained in:
parent
081a0c943f
commit
da58926ac5
16
src/redis.c
16
src/redis.c
@ -1453,6 +1453,7 @@ void initServerConfig(void) {
|
|||||||
server.assert_line = 0;
|
server.assert_line = 0;
|
||||||
server.bug_report_start = 0;
|
server.bug_report_start = 0;
|
||||||
server.watchdog_period = 0;
|
server.watchdog_period = 0;
|
||||||
|
server.use_cmd_time_accounting = 0; /* XXX: this should be configurable. */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function will try to raise the max number of open files accordingly to
|
/* This function will try to raise the max number of open files accordingly to
|
||||||
@ -1932,6 +1933,9 @@ void forceCommandPropagation(redisClient *c, int flags) {
|
|||||||
/* Call() is the core of Redis execution of a command */
|
/* Call() is the core of Redis execution of a command */
|
||||||
void call(redisClient *c, int flags) {
|
void call(redisClient *c, int flags) {
|
||||||
long long dirty, start, duration;
|
long long dirty, start, duration;
|
||||||
|
int get_duration = server.latency_monitor_threshold != 0 ||
|
||||||
|
server.slowlog_log_slower_than != 0 ||
|
||||||
|
server.use_cmd_time_accounting != 0;
|
||||||
int client_old_flags = c->flags;
|
int client_old_flags = c->flags;
|
||||||
|
|
||||||
/* Sent the command to clients in MONITOR mode, only if the commands are
|
/* Sent the command to clients in MONITOR mode, only if the commands are
|
||||||
@ -1947,9 +1951,9 @@ void call(redisClient *c, int flags) {
|
|||||||
c->flags &= ~(REDIS_FORCE_AOF|REDIS_FORCE_REPL);
|
c->flags &= ~(REDIS_FORCE_AOF|REDIS_FORCE_REPL);
|
||||||
redisOpArrayInit(&server.also_propagate);
|
redisOpArrayInit(&server.also_propagate);
|
||||||
dirty = server.dirty;
|
dirty = server.dirty;
|
||||||
start = ustime();
|
if (get_duration) start = ustime();
|
||||||
c->cmd->proc(c);
|
c->cmd->proc(c);
|
||||||
duration = ustime()-start;
|
if (get_duration) duration = ustime()-start;
|
||||||
dirty = server.dirty-dirty;
|
dirty = server.dirty-dirty;
|
||||||
if (dirty < 0) dirty = 0;
|
if (dirty < 0) dirty = 0;
|
||||||
|
|
||||||
@ -1970,14 +1974,18 @@ void call(redisClient *c, int flags) {
|
|||||||
|
|
||||||
/* Log the command into the Slow log if needed, and populate the
|
/* Log the command into the Slow log if needed, and populate the
|
||||||
* per-command statistics that we show in INFO commandstats. */
|
* per-command statistics that we show in INFO commandstats. */
|
||||||
if (flags & REDIS_CALL_SLOWLOG && c->cmd->proc != execCommand) {
|
if (get_duration &&
|
||||||
|
flags & REDIS_CALL_SLOWLOG &&
|
||||||
|
c->cmd->proc != execCommand)
|
||||||
|
{
|
||||||
char *latency_event = (c->cmd->flags & REDIS_CMD_FAST) ?
|
char *latency_event = (c->cmd->flags & REDIS_CMD_FAST) ?
|
||||||
"fast-command" : "command";
|
"fast-command" : "command";
|
||||||
latencyAddSampleIfNeeded(latency_event,duration/1000);
|
latencyAddSampleIfNeeded(latency_event,duration/1000);
|
||||||
slowlogPushEntryIfNeeded(c->argv,c->argc,duration);
|
slowlogPushEntryIfNeeded(c->argv,c->argc,duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & REDIS_CALL_STATS) {
|
if (flags & REDIS_CALL_STATS) {
|
||||||
c->cmd->microseconds += duration;
|
if (server.use_cmd_time_accounting) c->cmd->microseconds += duration;
|
||||||
c->cmd->calls++;
|
c->cmd->calls++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,6 +666,7 @@ struct redisServer {
|
|||||||
size_t resident_set_size; /* RSS sampled in serverCron(). */
|
size_t resident_set_size; /* RSS sampled in serverCron(). */
|
||||||
long long stat_net_input_bytes; /* Bytes read from network. */
|
long long stat_net_input_bytes; /* Bytes read from network. */
|
||||||
long long stat_net_output_bytes; /* Bytes written to network. */
|
long long stat_net_output_bytes; /* Bytes written to network. */
|
||||||
|
int use_cmd_time_accounting; /* commandstats time accounting. */
|
||||||
/* The following two are used to track instantaneous metrics, like
|
/* The following two are used to track instantaneous metrics, like
|
||||||
* number of operations per second, network traffic. */
|
* number of operations per second, network traffic. */
|
||||||
struct {
|
struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user