Slabbed hash table. Drops contention on hash table main lock.

git-svn-id: file:///svn/unbound/trunk@194 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards
2007-03-23 15:17:11 +00:00
parent 2092d6535a
commit f559c3c2ca
11 changed files with 711 additions and 12 deletions
+6 -1
View File
@@ -72,6 +72,7 @@ static hashvalue_t myhash(int id) {return (hashvalue_t)id & 0x0f;}
/** allocate new key, fill in hash. */
static struct testkey* newkey(int id) {
struct testkey* k = (struct testkey*)calloc(1, sizeof(struct testkey));
if(!k) fatal_exit("out of memory");
k->id = id;
k->entry.hash = myhash(id);
k->entry.key = k;
@@ -82,6 +83,7 @@ static struct testkey* newkey(int id) {
static struct testdata* newdata(int val) {
struct testdata* d = (struct testdata*)calloc(1,
sizeof(struct testdata));
if(!d) fatal_exit("out of memory");
d->data = val;
return d;
}
@@ -102,6 +104,7 @@ test_bin_find_entry(struct lruhash* table)
struct testkey* k4 = newkey(12 + 1024*2);
hashvalue_t h = myhash(12);
struct lruhash_bin bin;
memset(&bin, 0, sizeof(bin));
bin_init(&bin, 1);
/* remove from empty list */
@@ -488,7 +491,9 @@ void lruhash_test()
{
/* start very very small array, so it can do lots of table_grow() */
/* also small in size so that reclaim has to be done quickly. */
struct lruhash* table = lruhash_create(2, 4096,
struct lruhash* table ;
printf("lruhash test\n");
table = lruhash_create(2, 4096,
test_sizefunc, test_compfunc, test_delkey, test_deldata, NULL);
test_bin_find_entry(table);
test_lru(table);