summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorContinuous Integration <ci@tangent.org>2014-02-06 02:28:46 -0800
committerContinuous Integration <ci@tangent.org>2014-02-06 02:28:46 -0800
commit8541a9863cffad457f4d583af6a6c3613250193d (patch)
tree2fc0995d2669ca6967ee34b14b9099d00623a734
parentd87b5f2ec450afd521e7ebf556c3a9cddbc22e99 (diff)
parent5e5e924069514220c5c4bf76e3f125b44dc09bb9 (diff)
downloadlibmemcached-8541a9863cffad457f4d583af6a6c3613250193d.tar.gz
Merge lp:~vbernat/libmemcached/fix-memaslap-tps Build: jenkins-Libmemcached-455
-rw-r--r--clients/ms_conn.c20
-rw-r--r--clients/ms_conn.h1
-rw-r--r--clients/ms_task.c6
3 files changed, 26 insertions, 1 deletions
diff --git a/clients/ms_conn.c b/clients/ms_conn.c
index 2afc9fa1..42bb10e7 100644
--- a/clients/ms_conn.c
+++ b/clients/ms_conn.c
@@ -2473,7 +2473,7 @@ static bool ms_need_yield(ms_conn_t *c)
{
gettimeofday(&curr_time, NULL);
time_diff= ms_time_diff(&ms_thread->startup_time, &curr_time);
- tps= (int64_t)(((task->get_opt + task->set_opt) / (uint64_t)time_diff) * 1000000);
+ tps= (uint64_t)(task->get_opt + task->set_opt) * 1000000 / (uint64_t)time_diff;
/* current throughput is greater than expected throughput */
if (tps > ms_thread->thread_ctx->tps_perconn)
@@ -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);