diff options
author | dormando <dormando@rydia.net> | 2019-09-30 16:44:35 -0700 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2019-09-30 18:17:46 -0700 |
commit | e3d97fd12af49615cd682fc9d9e83d3df91e8c42 (patch) | |
tree | 38278b8c405f0401a32d3f18b151f2ea6e337a06 /items.c | |
parent | 8b15e085f8871d81749299e92d9dca75278e2087 (diff) | |
download | memcached-e3d97fd12af49615cd682fc9d9e83d3df91e8c42.tar.gz |
Keep "last access" time up to date in SLRU mode
The last access time used to only update once per minute to avoid
excess bumping on hot items. However, with segmented mode if an item is
hit a lot it's simply poked in place.
Previous to this change we were calling extra functions and branches
for no real reason. Also when bumping within the WARM_LRU, we were
updating the last access time despite it being a shuffle. Also it was
skipping the bump if the access time was too recent, which is one hell
of a bug.
Diffstat (limited to 'items.c')
-rw-r--r-- | items.c | 22 |
1 files changed, 4 insertions, 18 deletions
@@ -544,21 +544,6 @@ void do_item_remove(item *it) { } } -/* Copy/paste to avoid adding two extra branches for all common calls, since - * _nolock is only used in an uncommon case where we want to relink. */ -void do_item_update_nolock(item *it) { - MEMCACHED_ITEM_UPDATE(ITEM_key(it), it->nkey, it->nbytes); - if (it->time < current_time - ITEM_UPDATE_INTERVAL) { - assert((it->it_flags & ITEM_SLABBED) == 0); - - if ((it->it_flags & ITEM_LINKED) != 0) { - do_item_unlink_q(it); - it->time = current_time; - do_item_link_q(it); - } - } -} - /* Bump the last accessed time, or relink if we're in compat mode */ void do_item_update(item *it) { MEMCACHED_ITEM_UPDATE(ITEM_key(it), it->nkey, it->nbytes); @@ -574,7 +559,7 @@ void do_item_update(item *it) { it->slabs_clsid |= WARM_LRU; it->it_flags &= ~ITEM_ACTIVE; item_link_q_warm(it); - } else if (it->time < current_time - ITEM_UPDATE_INTERVAL) { + } else { it->time = current_time; } } @@ -1066,7 +1051,7 @@ void do_item_bump(conn *c, item *it, const uint32_t hv) { } else { it->it_flags |= ITEM_ACTIVE; if (ITEM_lruid(it) != COLD_LRU) { - do_item_update(it); // bump LA time + it->time = current_time; // only need to bump time. } else if (!lru_bump_async(c->thread->lru_bump_buf, it, hv)) { // add flag before async bump to avoid race. it->it_flags &= ~ITEM_ACTIVE; @@ -1182,7 +1167,8 @@ int lru_pull_tail(const int orig_id, const int cur_lru, removed++; if (cur_lru == WARM_LRU) { itemstats[id].moves_within_lru++; - do_item_update_nolock(search); + do_item_unlink_q(search); + do_item_link_q(search); do_item_remove(search); item_trylock_unlock(hold_lock); } else { |