diff options
author | Vincent Bernat <bernat@luffy.cx> | 2014-01-11 20:56:03 +0100 |
---|---|---|
committer | Vincent Bernat <bernat@luffy.cx> | 2014-01-11 20:56:03 +0100 |
commit | 5e5e924069514220c5c4bf76e3f125b44dc09bb9 (patch) | |
tree | 92afdc6d2a07a479aa0b9e74e4145a65116d3ec3 | |
parent | f81b9d07098f631a2284f38e8b44478b087e5bf4 (diff) | |
download | libmemcached-5e5e924069514220c5c4bf76e3f125b44dc09bb9.tar.gz |
Don't account for time in throttled state.
When we get throttled, we set a timer to be able to remove the time
where we are just waiting throttled. This makes timing metrics more
accurate.
-rw-r--r-- | clients/ms_conn.c | 18 | ||||
-rw-r--r-- | clients/ms_conn.h | 1 | ||||
-rw-r--r-- | clients/ms_task.c | 6 |
3 files changed, 25 insertions, 0 deletions
diff --git a/clients/ms_conn.c b/clients/ms_conn.c index 0c2cf090..42bb10e7 100644 --- a/clients/ms_conn.c +++ b/clients/ms_conn.c @@ -2499,6 +2499,7 @@ static void ms_update_start_time(ms_conn_t *c) || ((c->currcmd.cmd == CMD_SET) && (item->exp_time > 0))) { gettimeofday(&c->start_time, NULL); + memset(&c->throttle_time, 0, sizeof(c->start_time)); if ((c->currcmd.cmd == CMD_SET) && (item->exp_time > 0)) { /* record the current time */ @@ -2509,6 +2510,22 @@ static void ms_update_start_time(ms_conn_t *c) /** + * used to update the throttle time of each operation + * + * @param c, pointer of the concurrency + */ +static void ms_update_throttle_time(ms_conn_t *c) +{ + if ((ms_setting.stat_freq > 0) + && (c->throttle_time.tv_usec == 0) + && (c->throttle_time.tv_sec ==0)) + { + gettimeofday(&c->throttle_time, NULL); + } +} /* ms_update_throttle_time */ + + +/** * run the state machine * * @param c, pointer of the concurrency @@ -2567,6 +2584,7 @@ static void ms_drive_machine(ms_conn_t *c) case conn_write: if (! c->ctnwrite && ms_need_yield(c)) { + ms_update_throttle_time(c); usleep(10); if (! ms_update_event(c, EV_WRITE | EV_PERSIST)) diff --git a/clients/ms_conn.h b/clients/ms_conn.h index b915888d..479a4706 100644 --- a/clients/ms_conn.h +++ b/clients/ms_conn.h @@ -192,6 +192,7 @@ typedef struct conn /* response time statistic and time out control */ struct timeval start_time; /* start time of current operation(s) */ struct timeval end_time; /* end time of current operation(s) */ + struct timeval throttle_time; /* start time where we started throttling */ /* Binary protocol stuff */ protocol_binary_response_header binary_header; /* local temporary binary header */ diff --git a/clients/ms_task.c b/clients/ms_task.c index 636f8be7..0a98a941 100644 --- a/clients/ms_task.c +++ b/clients/ms_task.c @@ -972,6 +972,12 @@ static void ms_update_stat_result(ms_conn_t *c) gettimeofday(&c->end_time, NULL); uint64_t time_diff= (uint64_t)ms_time_diff(&c->start_time, &c->end_time); + if ((c->throttle_time.tv_usec != 0) + || (c->throttle_time.tv_sec != 0)) + { + uint64_t throttle_time = (uint64_t)ms_time_diff(&c->throttle_time, &c->end_time); + time_diff -= throttle_time; + } pthread_mutex_lock(&ms_statistic.stat_mutex); |