summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2017-01-09 00:32:22 -0800
committerdormando <dormando@rydia.net>2017-01-22 19:47:50 -0800
commite87ab394f383acd43076ee1127f1b403882263db (patch)
tree8a491be958a6d0f1b8c5be77a0b244b26eb6064b /thread.c
parent312ae0d2382f970b556b64bc63a383f83954ab2d (diff)
downloadmemcached-e87ab394f383acd43076ee1127f1b403882263db.tar.gz
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.
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c16
1 files changed, 2 insertions, 14 deletions
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;
}
@@ -611,18 +611,6 @@ void item_unlink(item *item) {
}
/*
- * 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.
*/
enum delta_result_type add_delta(conn *c, const char *key,