From e87ab394f383acd43076ee1127f1b403882263db Mon Sep 17 00:00:00 2001 From: dormando Date: Mon, 9 Jan 2017 00:32:22 -0800 Subject: Do LRU-bumps while already holding item lock item_get() would hash, item_lock, fetch item. consumers which can bump the LRU would then call item_update(), which would hash, item_lock, then update the item. Good performance bump by inlining the LRU bump when it's necessary. --- thread.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'thread.c') diff --git a/thread.c b/thread.c index 0a01eed..2908d57 100644 --- a/thread.c +++ b/thread.c @@ -543,12 +543,12 @@ item *item_alloc(char *key, size_t nkey, int flags, rel_time_t exptime, int nbyt * Returns an item if it hasn't been marked as expired, * lazy-expiring as needed. */ -item *item_get(const char *key, const size_t nkey, conn *c) { +item *item_get(const char *key, const size_t nkey, conn *c, const bool do_update) { item *it; uint32_t hv; hv = hash(key, nkey); item_lock(hv); - it = do_item_get(key, nkey, hv, c); + it = do_item_get(key, nkey, hv, c, do_update); item_unlock(hv); return it; } @@ -610,18 +610,6 @@ void item_unlink(item *item) { item_unlock(hv); } -/* - * Moves an item to the back of the LRU queue. - */ -void item_update(item *item) { - uint32_t hv; - hv = hash(ITEM_key(item), item->nkey); - - item_lock(hv); - do_item_update(item); - item_unlock(hv); -} - /* * Does arithmetic on a numeric item value. */ -- cgit v1.2.1