diff options
author | dormando <dormando@rydia.net> | 2017-01-09 01:03:09 -0800 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2017-01-22 19:47:50 -0800 |
commit | ea773779cdf8621c4d1ca13fed2fff4c239d3608 (patch) | |
tree | 1f1e915a686b2ffd4f522453623e0a703e5ee393 /crawler.c | |
parent | dcdcd8a551e4af2210b750bc848ec7daf967d938 (diff) | |
download | memcached-ea773779cdf8621c4d1ca13fed2fff4c239d3608.tar.gz |
stop using atomics for item refcount management
when I first split the locks up further I had a trick where "item_remove()"
did not require holding the associated item lock. If an item were to be freed,
it would then do the necessary work.;
Since then, all calls to refcount_incr and refcount_decr only happen while the
item is locked. This was mostly due to the slab mover being very tricky with
locks. The atomic is no longer needed as the refcount is only ever checked
after a lock to the item.
Calling atomics is pretty expensive, especially in multicore/multisocket
scenarios. This yields a notable performance increase.
Diffstat (limited to 'crawler.c')
-rw-r--r-- | crawler.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -199,7 +199,7 @@ static void crawler_expired_eval(crawler_module_t *cm, item *search, uint32_t hv assert(search->slabs_clsid == 0); } else { s->seen++; - refcount_decr(&search->refcount); + refcount_decr(search); if (search->exptime == 0) { s->noexp++; } else if (search->exptime - current_time > 3599) { @@ -220,7 +220,7 @@ static void crawler_metadump_eval(crawler_module_t *cm, item *it, uint32_t hv, i /* Ignore expired content. */ if ((it->exptime != 0 && it->exptime < current_time) || is_flushed) { - refcount_decr(&it->refcount); + refcount_decr(it); return; } // TODO: uriencode directly into the buffer. @@ -232,7 +232,7 @@ static void crawler_metadump_eval(crawler_module_t *cm, item *it, uint32_t hv, i (unsigned long long)it->time + process_started, (unsigned long long)ITEM_get_cas(it), (it->it_flags & ITEM_FETCHED) ? "yes" : "no"); - refcount_decr(&it->refcount); + refcount_decr(it); // TODO: some way of tracking the errors. these are very unlikely though. if (total >= LRU_CRAWLER_WRITEBUF - 1 || total <= 0) { /* Failed to write, don't push it. */ @@ -366,8 +366,8 @@ static void *item_crawler_thread(void *arg) { continue; } /* Now see if the item is refcount locked */ - if (refcount_incr(&search->refcount) != 2) { - refcount_decr(&search->refcount); + if (refcount_incr(search) != 2) { + refcount_decr(search); if (hold_lock) item_trylock_unlock(hold_lock); pthread_mutex_unlock(&lru_locks[i]); |