summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIliya <vnsavage@gmail.com>2022-03-21 15:20:34 +0200
committerdormando <dormando@rydia.net>2022-08-22 12:56:09 -0700
commite183fa37d7bbabd6499b73afcc39e2c579bebfae (patch)
treeeafe4431018e2a7f788ca884ea6fcdab7c604bd3
parent2004865efe1e8da24f7182b233246298ed5cf56e (diff)
downloadmemcached-e183fa37d7bbabd6499b73afcc39e2c579bebfae.tar.gz
Improve Slab Automove behavior
- Skip using crawler items when calculating the automover age stats as they can severly skew the ages in the stats to the point of completely starving particular slabs - Include the current window data in the window sum so we don't free pages that are actually needed - this also matches the python script behavior - Reset young / old when interrupting the automove decision loop so we don't accidentally move things which we didn't mean to
-rw-r--r--items.c13
-rw-r--r--slab_automove.c8
2 files changed, 15 insertions, 6 deletions
diff --git a/items.c b/items.c
index 65de923..e5347cc 100644
--- a/items.c
+++ b/items.c
@@ -660,10 +660,17 @@ void fill_item_stats_automove(item_stats_automove *am) {
i = n | COLD_LRU;
pthread_mutex_lock(&lru_locks[i]);
cur->evicted = itemstats[i].evicted;
- if (tails[i]) {
- cur->age = current_time - tails[i]->time;
- } else {
+ if (!tails[i]) {
cur->age = 0;
+ } else if (tails[i]->nbytes == 0 && tails[i]->nkey == 0 && tails[i]->it_flags == 1) {
+ /* it's a crawler, check previous entry */
+ if (tails[i]->prev) {
+ cur->age = current_time - tails[i]->prev->time;
+ } else {
+ cur->age = 0;
+ }
+ } else {
+ cur->age = current_time - tails[i]->time;
}
pthread_mutex_unlock(&lru_locks[i]);
}
diff --git a/slab_automove.c b/slab_automove.c
index c2a1180..40ee831 100644
--- a/slab_automove.c
+++ b/slab_automove.c
@@ -98,9 +98,6 @@ void slab_automove_run(void *arg, int *src, int *dst) {
int w_offset = n * a->window_size;
struct window_data *wd = &a->window_data[w_offset + (a->window_cur % a->window_size)];
memset(wd, 0, sizeof(struct window_data));
- // summarize the window-up-to-now.
- memset(&w_sum, 0, sizeof(struct window_data));
- window_sum(&a->window_data[w_offset], &w_sum, a->window_size);
// if page delta, or evicted delta, mark window dirty
// (or outofmemory)
@@ -122,6 +119,10 @@ void slab_automove_run(void *arg, int *src, int *dst) {
// set age into window
wd->age = a->iam_after[n].age;
+ // summarize the window-up-to-now.
+ memset(&w_sum, 0, sizeof(struct window_data));
+ window_sum(&a->window_data[w_offset], &w_sum, a->window_size);
+
// grab age as average of window total
uint64_t age = w_sum.age / a->window_size;
@@ -130,6 +131,7 @@ void slab_automove_run(void *arg, int *src, int *dst) {
if (w_sum.dirty == 0) {
*src = n;
*dst = 0;
+ youngest = oldest = -1;
break;
}
}