diff options
author | dormando <dormando@rydia.net> | 2011-10-02 01:23:46 -0700 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2011-11-09 16:06:08 -0800 |
commit | bab9acd115828e44176a3671bd65089d6fdeff85 (patch) | |
tree | 9230ad6621ab3bed65778000730c2c162cb72ca7 /assoc.c | |
parent | 45e0e9500f11783e227898c7af66a4b5c0057f41 (diff) | |
download | memcached-bab9acd115828e44176a3671bd65089d6fdeff85.tar.gz |
move hash calls outside of cache_lock
been hard to measure while using the intel hash (since it's very fast), but
should help with the software hash.
Diffstat (limited to 'assoc.c')
-rw-r--r-- | assoc.c | 16 |
1 files changed, 6 insertions, 10 deletions
@@ -73,8 +73,7 @@ void assoc_init(const int hashtable_init) { STATS_UNLOCK(); } -item *assoc_find(const char *key, const size_t nkey) { - uint32_t hv = hash(key, nkey, 0); +item *assoc_find(const char *key, const size_t nkey, const uint32_t hv) { item *it; unsigned int oldbucket; @@ -103,8 +102,7 @@ item *assoc_find(const char *key, const size_t nkey) { /* returns the address of the item pointer before the key. if *item == 0, the item wasn't found */ -static item** _hashitem_before (const char *key, const size_t nkey) { - uint32_t hv = hash(key, nkey, 0); +static item** _hashitem_before (const char *key, const size_t nkey, const uint32_t hv) { item **pos; unsigned int oldbucket; @@ -146,13 +144,11 @@ static void assoc_expand(void) { } /* Note: this isn't an assoc_update. The key must not already exist to call this */ -int assoc_insert(item *it) { - uint32_t hv; +int assoc_insert(item *it, const uint32_t hv) { unsigned int oldbucket; - assert(assoc_find(ITEM_key(it), it->nkey) == 0); /* shouldn't have duplicately named things defined */ +// assert(assoc_find(ITEM_key(it), it->nkey) == 0); /* shouldn't have duplicately named things defined */ - hv = hash(ITEM_key(it), it->nkey, 0); if (expanding && (oldbucket = (hv & hashmask(hashpower - 1))) >= expand_bucket) { @@ -172,8 +168,8 @@ int assoc_insert(item *it) { return 1; } -void assoc_delete(const char *key, const size_t nkey) { - item **before = _hashitem_before(key, nkey); +void assoc_delete(const char *key, const size_t nkey, const uint32_t hv) { + item **before = _hashitem_before(key, nkey, hv); if (*before) { item *nxt; |