Skip to content

Commit

Permalink
reap items on read for slab mover
Browse files Browse the repository at this point in the history
popular items could stuck the slab mover forever, so if a move is in progress,
check to see if the item we're fetching should be unlinked instead.
  • Loading branch information
dormando committed Jan 5, 2012
1 parent 8c1c18e commit b3630e1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion items.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,18 @@ void do_item_stats_sizes(ADD_STAT add_stats, void *c) {
item *do_item_get(const char *key, const size_t nkey, const uint32_t hv) {
mutex_lock(&cache_lock);
item *it = assoc_find(key, nkey, hv);
if (it != NULL)
if (it != NULL) {
it->refcount++;
/* Optimization for slab reassignment. prevents popular items from
* jamming in busy wait. Can only do this here to satisfy lock order
* of item_lock, cache_lock, slabs_lock. */
if (slab_rebalance_signal &&
((void *)it >= slab_rebal.slab_start && (void *)it < slab_rebal.slab_end)) {
it->refcount--;
do_item_unlink_nolock(it, hv);
it = NULL;
}
}
pthread_mutex_unlock(&cache_lock);
int was_found = 0;

Expand Down

0 comments on commit b3630e1

Please sign in to comment.