When assigning a bucket lock to an rbt node, use the hash of the full name,
rather than the hash of the partial name stored in the node. This more evenly distributes nodes across locks. This change only takes effect when DNS_RBT_USEHASH is defined, and also changes the rbt so that the hashtable is created when the first node is created in the tree, not after 64 nodes are added.
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: rbt.c,v 1.100 2001/02/05 20:07:20 bwelling Exp $ */
|
||||
/* $Id: rbt.c,v 1.101 2001/02/09 01:26:49 bwelling Exp $ */
|
||||
|
||||
/* Principal Authors: DCL */
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
#ifdef RBT_MEM_TEST
|
||||
#undef RBT_HASH_SIZE
|
||||
#define RBT_HASH_SIZE 1 /* To give the reallocation code a workout. */
|
||||
#define RBT_HASH_SIZE 2 /* To give the reallocation code a workout. */
|
||||
#endif
|
||||
|
||||
struct dns_rbt {
|
||||
@@ -1621,7 +1621,7 @@ static isc_result_t
|
||||
inithash(dns_rbt_t *rbt) {
|
||||
unsigned int bytes;
|
||||
|
||||
rbt->hashsize = RBT_HASH_SIZE * 2;
|
||||
rbt->hashsize = RBT_HASH_SIZE;
|
||||
bytes = rbt->hashsize * sizeof(dns_rbtnode_t *);
|
||||
rbt->hashtable = isc_mem_get(rbt->mctx, bytes);
|
||||
|
||||
@@ -1675,12 +1675,9 @@ static inline isc_result_t
|
||||
hash_node(dns_rbt_t *rbt, dns_rbtnode_t *node) {
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
|
||||
if (rbt->hashtable == NULL) {
|
||||
if (rbt->nodecount == RBT_HASH_SIZE)
|
||||
result = inithash(rbt);
|
||||
return (result);
|
||||
|
||||
} else if (rbt->nodecount >= rbt->hashsize)
|
||||
if (rbt->hashtable == NULL)
|
||||
result = inithash(rbt);
|
||||
else if (rbt->nodecount >= rbt->hashsize)
|
||||
result = rehash(rbt);
|
||||
|
||||
if (result == ISC_R_SUCCESS)
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: rbtdb.c,v 1.146 2001/01/30 02:50:45 bwelling Exp $ */
|
||||
/* $Id: rbtdb.c,v 1.147 2001/02/09 01:26:51 bwelling Exp $ */
|
||||
|
||||
/*
|
||||
* Principal Author: Bob Halley
|
||||
@@ -984,8 +984,12 @@ findnode(dns_db_t *db, dns_name_t *name, isc_boolean_t create,
|
||||
result = dns_rbt_addnode(rbtdb->tree, name, &node);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
dns_rbt_namefromnode(node, &nodename);
|
||||
#ifdef DNS_RBT_USEHASH
|
||||
node->locknum = node->hashval % rbtdb->node_lock_count;
|
||||
#else
|
||||
node->locknum = dns_name_hash(&nodename, ISC_TRUE) %
|
||||
rbtdb->node_lock_count;
|
||||
#endif
|
||||
} else if (result != ISC_R_EXISTS) {
|
||||
RWUNLOCK(&rbtdb->tree_lock, locktype);
|
||||
return (result);
|
||||
@@ -3709,8 +3713,12 @@ loading_addrdataset(void *arg, dns_name_t *name, dns_rdataset_t *rdataset) {
|
||||
if (result != ISC_R_EXISTS) {
|
||||
dns_name_init(&foundname, NULL);
|
||||
dns_rbt_namefromnode(node, &foundname);
|
||||
#ifdef DNS_RBT_USEHASH
|
||||
node->locknum = node->hashval % rbtdb->node_lock_count;
|
||||
#else
|
||||
node->locknum = dns_name_hash(&foundname, ISC_TRUE) %
|
||||
rbtdb->node_lock_count;
|
||||
#endif
|
||||
}
|
||||
|
||||
result = dns_rdataslab_fromrdataset(rdataset, rbtdb->common.mctx,
|
||||
@@ -4080,9 +4088,15 @@ dns_rbtdb_create
|
||||
*/
|
||||
dns_name_init(&name, NULL);
|
||||
dns_rbt_namefromnode(rbtdb->origin_node, &name);
|
||||
#ifdef DNS_RBT_USEHASH
|
||||
rbtdb->origin_node->locknum =
|
||||
rbtdb->origin_node->hashval %
|
||||
rbtdb->node_lock_count;
|
||||
#else
|
||||
rbtdb->origin_node->locknum =
|
||||
dns_name_hash(&name, ISC_TRUE) %
|
||||
rbtdb->node_lock_count;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user