summaryrefslogtreecommitdiff
path: root/items.c
diff options
context:
space:
mode:
authorGrant Mathews <grant.m.mathews@gmail.com>2017-02-17 16:04:37 -0800
committerdormando <dormando@rydia.net>2017-05-22 22:28:29 -0700
commitf0a3c4954fccc178c8e3e1948ff58cb3279d9783 (patch)
tree665188c658fd1fd21e7196874b5f67453c864892 /items.c
parenta8c4a82787b8b6c256d61bd5c42fb7f92d1bae00 (diff)
downloadmemcached-f0a3c4954fccc178c8e3e1948ff58cb3279d9783.tar.gz
Sleep more aggressively in some threads
The logger and lru maintainer threads both adjust how long they sleep based on how busy they are. This adjustment should be exponential, to more quickly adjust to workloads. The logger thread in particular would only adjust 50 microseconds at a time, and was capped at 100 milliseconds of sleep, causing many unnecessary wakeups on an otherwise idle dev machine. Adjust this cap to 1 second.
Diffstat (limited to 'items.c')
-rw-r--r--items.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/items.c b/items.c
index 8bd7d18..f3822ef 100644
--- a/items.c
+++ b/items.c
@@ -1453,11 +1453,13 @@ static void *lru_maintainer_thread(void *arg) {
int did_moves = lru_maintainer_juggle(i);
if (did_moves == 0) {
if (backoff_juggles[i] < MAX_LRU_MAINTAINER_SLEEP)
- backoff_juggles[i] += 1000;
+ backoff_juggles[i] += backoff_juggles[i] / 8;
+ 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] = 0;
+ backoff_juggles[i] = MIN_LRU_MAINTAINER_SLEEP;
}
}
next_juggles[i] = backoff_juggles[i];