memcached/memcached — pull request #90 by zwChan (2014-12-04 03:03:02+00:00)
Title: Remove the global lock, make the hash table expanding simpler and grace

Several months ago, I pushed a post on the google group to discuss about global lock when hash table expanding. When trying to do that some days ago, I found it is much simpler than the discuss. We can use only one item_lock when expanding.
Both bucket of hash table and item_locks are evaluate by " bucket = hv & hashmask(mask)", so the bucket of hash table is the lowest N bits of the hv, and the bucket of item_locks is also the lowest M bits of hv. N should be greater than M(by default N is 16, M is 12). Because the expanding is add a bit at the highest of 'bucket', it does not change the item lock. Both of new bucket and old bucket use the same item lock. So we can process expanding with only one item_lock. cool!
After remove global lock, the expanding can process concurrently with slabs_rebalancer, since they hold item_lock.