diff options
author | dormando <dormando@rydia.net> | 2017-05-28 15:14:06 -0700 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2017-05-28 15:14:06 -0700 |
commit | 675d89d784dfa411ce1b272b97bc04039631c53b (patch) | |
tree | 7cfa69fb008ed0b303fab7dfbafa72492ca350ef /items.c | |
parent | 79e35287df4cd9e410c3a160c2552ea40a335e2c (diff) | |
download | memcached-675d89d784dfa411ce1b272b97bc04039631c53b.tar.gz |
fix lru thread sleeper more
added a bug which caused LRU juggler to never sleep. increased max sleep time
to 1s.
also fixed a bug where every other LRU round had a 0 sleep.
there's still wakeup overkill once one slab class becomes active, it will
"desync" from the amount of sleep required for other slab classes. They will
pull the LRU once per second, but the thread wakes up, up to the number of
active slab classes per second.
deprioritizing, but a clean way of re-syncing the slab classes would minimize
wakeups.
Diffstat (limited to 'items.c')
-rw-r--r-- | items.c | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -1402,7 +1402,7 @@ static void lru_maintainer_crawler_check(struct crawler_expired_data *cdata, log static pthread_t lru_maintainer_tid; -#define MAX_LRU_MAINTAINER_SLEEP 500000 +#define MAX_LRU_MAINTAINER_SLEEP 1000000 #define MIN_LRU_MAINTAINER_SLEEP 1000 static void *lru_maintainer_thread(void *arg) { @@ -1443,26 +1443,31 @@ static void *lru_maintainer_thread(void *arg) { for (i = POWER_SMALLEST; i < MAX_NUMBER_OF_SLAB_CLASSES; i++) { next_juggles[i] = next_juggles[i] > last_sleep ? next_juggles[i] - last_sleep : 0; - // Sleep the thread just for the minimum amount (or not at all) - if (next_juggles[i] < to_sleep) { - to_sleep = next_juggles[i]; - } - if (next_juggles[i] > 0) + if (next_juggles[i] > 0) { + // Sleep the thread just for the minimum amount (or not at all) + if (next_juggles[i] < to_sleep) + to_sleep = next_juggles[i]; continue; + } int did_moves = lru_maintainer_juggle(i); if (did_moves == 0) { - if (backoff_juggles[i] < MAX_LRU_MAINTAINER_SLEEP) + if (backoff_juggles[i] != 0) { backoff_juggles[i] += backoff_juggles[i] / 8; + } else { + backoff_juggles[i] = MIN_LRU_MAINTAINER_SLEEP; + } if (backoff_juggles[i] > MAX_LRU_MAINTAINER_SLEEP) backoff_juggles[i] = MAX_LRU_MAINTAINER_SLEEP; } else if (backoff_juggles[i] > 0) { backoff_juggles[i] /= 2; if (backoff_juggles[i] < MIN_LRU_MAINTAINER_SLEEP) { - backoff_juggles[i] = MIN_LRU_MAINTAINER_SLEEP; + backoff_juggles[i] = 0; } } next_juggles[i] = backoff_juggles[i]; + if (next_juggles[i] < to_sleep) + to_sleep = next_juggles[i]; } /* Minimize the sleep if we had async LRU bumps to process */ |