projects
/
m6w6
/
libmemcached
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
Update, we don't use gnulib
[m6w6/libmemcached]
/
clients
/
ms_task.c
diff --git
a/clients/ms_task.c
b/clients/ms_task.c
index 7a427332346e9dc2955942f1b3a5f768b378f459..7e7921fcf2b9b6cc44e17c84bfd39e1b5461c20f 100644
(file)
--- a/
clients/ms_task.c
+++ b/
clients/ms_task.c
@@
-12,6
+12,16
@@
#include "config.h"
#include <inttypes.h>
#include "config.h"
#include <inttypes.h>
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+# include <sys/time.h>
+# else
+# include <time.h>
+# endif
+#endif
#include "ms_thread.h"
#include "ms_setting.h"
#include "ms_thread.h"
#include "ms_setting.h"
@@
-30,7
+40,7
@@
static ms_task_item_t *ms_get_cur_opt_item(ms_conn_t *c);
static ms_task_item_t *ms_get_next_get_item(ms_conn_t *c);
static ms_task_item_t *ms_get_next_set_item(ms_conn_t *c);
static ms_task_item_t *ms_get_cur_opt_item(ms_conn_t *c);
static ms_task_item_t *ms_get_next_get_item(ms_conn_t *c);
static ms_task_item_t *ms_get_next_set_item(ms_conn_t *c);
-static ms_task_item_t *ms_get_
pre_set
_item(ms_conn_t *c);
+static ms_task_item_t *ms_get_
random_overwrite
_item(ms_conn_t *c);
/* select next operation to do */
/* select next operation to do */
@@
-44,7
+54,7
@@
static void ms_kick_out_item(ms_task_item_t *item);
/* miss rate adjustment */
/* miss rate adjustment */
-static bool ms_need_overw
ir
te_item(ms_task_t *task);
+static bool ms_need_overw
ri
te_item(ms_task_t *task);
static bool ms_adjust_opt(ms_conn_t *c, ms_task_t *task);
static bool ms_adjust_opt(ms_conn_t *c, ms_task_t *task);
@@
-144,18
+154,10
@@
static ms_task_item_t *ms_get_next_set_item(ms_conn_t *c)
* @return ms_task_item_t*, the pointer of the previous item of
* set operation
*/
* @return ms_task_item_t*, the pointer of the previous item of
* set operation
*/
-static ms_task_item_t *ms_get_
pre_set
_item(ms_conn_t *c)
+static ms_task_item_t *ms_get_
random_overwrite
_item(ms_conn_t *c)
{
{
- if (c->set_cursor <= 0)
- {
- return &c->item_win[0];
- }
- else
- {
- return &c->item_win[(int64_t)-- c->set_cursor % c->win_size];
- }
-} /* ms_get_pre_set_item */
-
+ return ms_get_next_get_item(c);
+} /* ms_get_random_overwrite_item */
/**
* According to the proportion of operations(get or set), select
/**
* According to the proportion of operations(get or set), select
@@
-291,7
+293,7
@@
static void ms_kick_out_item(ms_task_item_t *item)
* @return bool, if need overwrite, return true, else return
* false
*/
* @return bool, if need overwrite, return true, else return
* false
*/
-static bool ms_need_overw
ir
te_item(ms_task_t *task)
+static bool ms_need_overw
ri
te_item(ms_task_t *task)
{
ms_task_item_t *item= task->item;
{
ms_task_item_t *item= task->item;
@@
-345,7
+347,7
@@
static bool ms_adjust_opt(ms_conn_t *c, ms_task_t *task)
/* If the current item is not a new item, kick it out */
if (item->value_offset != INVALID_OFFSET)
{
/* If the current item is not a new item, kick it out */
if (item->value_offset != INVALID_OFFSET)
{
- if (ms_need_overw
ir
te_item(task))
+ if (ms_need_overw
ri
te_item(task))
{
/* overwrite */
task->overwrite_set++;
{
/* overwrite */
task->overwrite_set++;
@@
-359,17
+361,23
@@
static bool ms_adjust_opt(ms_conn_t *c, ms_task_t *task)
else /* it's a new item */
{
/* need overwrite */
else /* it's a new item */
{
/* need overwrite */
- if (ms_need_overw
ir
te_item(task))
+ if (ms_need_overw
ri
te_item(task))
{
{
- item= ms_get_pre_set_item(c);
+ /**
+ * overwrite not use the item with current set cursor, revert
+ * set cursor.
+ */
+ c->set_cursor--;
+
+ item= ms_get_random_overwrite_item(c);
if (item->value_offset != INVALID_OFFSET)
{
task->item= item;
task->overwrite_set++;
}
if (item->value_offset != INVALID_OFFSET)
{
task->item= item;
task->overwrite_set++;
}
- else /*
previous set
item is a new item */
+ else /* item is a new item */
{
{
- /* select the
previous
item to run, and cancel overwrite */
+ /* select the item to run, and cancel overwrite */
task->item= item;
}
}
task->item= item;
}
}
@@
-591,7
+599,7
@@
static void ms_warmup_server(ms_conn_t *c)
*/
if (c->remain_warmup_num == -1)
{
*/
if (c->remain_warmup_num == -1)
{
- ms_send_signal(&ms_global.
init
_lock);
+ ms_send_signal(&ms_global.
warmup
_lock);
c->remain_warmup_num--; /* never run the if branch */
}
} /* ms_warmup_server */
c->remain_warmup_num--; /* never run the if branch */
}
} /* ms_warmup_server */
@@
-619,7
+627,7
@@
static void ms_single_getset_task_sch(ms_conn_t *c)
else if (task->cmd == CMD_GET)
{
assert(task->cmd == CMD_GET);
else if (task->cmd == CMD_GET)
{
assert(task->cmd == CMD_GET);
- ms_mcd_get(c, item
, task->verify
);
+ ms_mcd_get(c, item);
}
}
} /* ms_single_getset_task_sch */
}
}
} /* ms_single_getset_task_sch */
@@
-725,7
+733,7
@@
static void ms_update_multi_get_result(ms_conn_t *c)
/* update get miss counter */
if (mlget_item->get_miss)
{
/* update get miss counter */
if (mlget_item->get_miss)
{
- atomic_add_
64
(&ms_stats.get_misses, 1);
+ atomic_add_
size
(&ms_stats.get_misses, 1);
}
/* get nothing from server for this task item */
}
/* get nothing from server for this task item */
@@
-741,7
+749,7
@@
static void ms_update_multi_get_result(ms_conn_t *c)
if (curr_time.tv_sec - item->client_time
< item->exp_time - EXPIRE_TIME_ERROR)
{
if (curr_time.tv_sec - item->client_time
< item->exp_time - EXPIRE_TIME_ERROR)
{
- atomic_add_
64
(&ms_stats.unexp_unget, 1);
+ atomic_add_
size
(&ms_stats.unexp_unget, 1);
if (ms_setting.verbose)
{
if (ms_setting.verbose)
{
@@
-779,7
+787,7
@@
static void ms_update_multi_get_result(ms_conn_t *c)
}
else
{
}
else
{
- atomic_add_
64
(&ms_stats.vef_miss, 1);
+ atomic_add_
size
(&ms_stats.vef_miss, 1);
if (ms_setting.verbose)
{
if (ms_setting.verbose)
{
@@
-829,7
+837,7
@@
static void ms_update_single_get_result(ms_conn_t *c, ms_task_item_t *item)
/* update get miss counter */
if ((c->precmd.cmd == CMD_GET) && c->curr_task.get_miss)
{
/* update get miss counter */
if ((c->precmd.cmd == CMD_GET) && c->curr_task.get_miss)
{
- atomic_add_
64
(&ms_stats.get_misses, 1);
+ atomic_add_
size
(&ms_stats.get_misses, 1);
}
/* get nothing from server for this task item */
}
/* get nothing from server for this task item */
@@
-846,7
+854,7
@@
static void ms_update_single_get_result(ms_conn_t *c, ms_task_item_t *item)
if (curr_time.tv_sec - item->client_time
< item->exp_time - EXPIRE_TIME_ERROR)
{
if (curr_time.tv_sec - item->client_time
< item->exp_time - EXPIRE_TIME_ERROR)
{
- atomic_add_
64
(&ms_stats.unexp_unget, 1);
+ atomic_add_
size
(&ms_stats.unexp_unget, 1);
if (ms_setting.verbose)
{
if (ms_setting.verbose)
{
@@
-884,7
+892,7
@@
static void ms_update_single_get_result(ms_conn_t *c, ms_task_item_t *item)
}
else
{
}
else
{
- atomic_add_
64
(&ms_stats.vef_miss, 1);
+ atomic_add_
size
(&ms_stats.vef_miss, 1);
if (ms_setting.verbose)
{
if (ms_setting.verbose)
{
@@
-1045,7
+1053,7
@@
static void ms_update_task_result(ms_conn_t *c)
*
* @param c, pointer of the concurrency
*
*
* @param c, pointer of the concurrency
*
- * @return int, if success, return
0
, else return -1
+ * @return int, if success, return
EXIT_SUCCESS
, else return -1
*/
static int ms_run_getset_task(ms_conn_t *c)
{
*/
static int ms_run_getset_task(ms_conn_t *c)
{
@@
-1077,7
+1085,7
@@
static int ms_run_getset_task(ms_conn_t *c)
return -1;
}
return -1;
}
- return
0
;
+ return
EXIT_SUCCESS
;
} /* ms_run_getset_task */
} /* ms_run_getset_task */
@@
-1086,7
+1094,7
@@
static int ms_run_getset_task(ms_conn_t *c)
*
* @param c, pointer of the concurrency
*
*
* @param c, pointer of the concurrency
*
- * @return int, if success, return
0
, else return -1
+ * @return int, if success, return
EXIT_SUCCESS
, else return -1
*/
int ms_exec_task(struct conn *c)
{
*/
int ms_exec_task(struct conn *c)
{
@@
-1102,5
+1110,5
@@
int ms_exec_task(struct conn *c)
}
}
}
}
- return
0
;
+ return
EXIT_SUCCESS
;
} /* ms_exec_task */
} /* ms_exec_task */