diff options
author | dormando <dormando@rydia.net> | 2017-01-08 01:10:45 -0800 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2017-01-22 19:56:08 -0800 |
commit | e1d9af2bcf853e1179a9ee2ac526bea435c50930 (patch) | |
tree | 8aaa36f52aab4a49a01a16ff893765a4549e10a2 /items.c | |
parent | e308807389190ea94d0df603359297101229fbc6 (diff) | |
download | memcached-e1d9af2bcf853e1179a9ee2ac526bea435c50930.tar.gz |
pull HOT tail if COLD+EVICT has no reclaims
The previous method would always pull both HOT and WARM before attempting to
pull COLD for eviction. This isn't the greatest performance, but simply
attempting to evict from COLD makes the code difficult to test. It also has a
bad effect if a ton of traffic comes in while the LRU maintainer has a high
sleep value, or sustained higher than the thread can keep up with.
A good tradeoff is simple; pull HOT tail if COLD+EVICT causes no reclaims,
then loop.
Tests now work again and should still be faster than old way in production.
Diffstat (limited to 'items.c')
-rw-r--r-- | items.c | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -193,10 +193,9 @@ item *do_item_alloc(char *key, const size_t nkey, const unsigned int flags, if (it == NULL) { if (settings.lru_maintainer_thread) { - //lru_pull_tail(id, HOT_LRU, total_bytes, 0); - //lru_pull_tail(id, WARM_LRU, total_bytes, 0); - if (lru_pull_tail(id, COLD_LRU, total_bytes, LRU_PULL_EVICT) <= 0) - break; + if (lru_pull_tail(id, COLD_LRU, total_bytes, LRU_PULL_EVICT) <= 0) { + lru_pull_tail(id, HOT_LRU, total_bytes, 0); + } } else { if (lru_pull_tail(id, COLD_LRU, 0, LRU_PULL_EVICT) <= 0) break; @@ -1170,7 +1169,7 @@ static void lru_maintainer_crawler_check(struct crawler_expired_data *cdata, log static pthread_t lru_maintainer_tid; -#define MAX_LRU_MAINTAINER_SLEEP 1000000 +#define MAX_LRU_MAINTAINER_SLEEP 500000 #define MIN_LRU_MAINTAINER_SLEEP 1000 static void *lru_maintainer_thread(void *arg) { |