mirror of
https://github.com/NLnetLabs/unbound.git
synced 2026-05-28 04:02:33 -04:00
Alloc cache per thread gets used for deleted items.
git-svn-id: file:///svn/unbound/trunk@280 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
4732f7c4d6
commit
caa76487f8
10 changed files with 29 additions and 21 deletions
|
|
@ -138,7 +138,7 @@ worker_store_rrsets(struct worker* worker, struct reply_info* rep)
|
|||
/* TODO: check if update really needed */
|
||||
slabhash_insert(worker->daemon->rrset_cache,
|
||||
rep->rrsets[i]->entry.hash, &rep->rrsets[i]->entry,
|
||||
rep->rrsets[i]->entry.data);
|
||||
rep->rrsets[i]->entry.data, &worker->alloc);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -200,7 +200,7 @@ worker_handle_reply(struct comm_point* c, void* arg, int error,
|
|||
return 0;
|
||||
}
|
||||
slabhash_insert(w->worker->daemon->msg_cache, w->query_hash,
|
||||
&e->entry, rep);
|
||||
&e->entry, rep, &w->worker->alloc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
4 May 2007: Wouter
|
||||
- msgreply sizefunc is more accurate.
|
||||
- config settings for rrset cache size and slabs.
|
||||
- hashtable insert takes argument so that a thread can use its own
|
||||
alloc cache to store released keys.
|
||||
|
||||
3 May 2007: Wouter
|
||||
- fill refs. Use new parse and encode to answer queries.
|
||||
|
|
|
|||
|
|
@ -233,8 +233,8 @@ test_short_table(struct lruhash* table)
|
|||
k->entry.data = d;
|
||||
k2->entry.data = d2;
|
||||
|
||||
lruhash_insert(table, myhash(12), &k->entry, d);
|
||||
lruhash_insert(table, myhash(14), &k2->entry, d2);
|
||||
lruhash_insert(table, myhash(12), &k->entry, d, NULL);
|
||||
lruhash_insert(table, myhash(14), &k2->entry, d2, NULL);
|
||||
|
||||
unit_assert( lruhash_lookup(table, myhash(12), k, 0) == &k->entry);
|
||||
lock_rw_unlock( &k->entry.lock );
|
||||
|
|
@ -255,7 +255,7 @@ testadd(struct lruhash* table, struct testdata* ref[])
|
|||
struct testdata* data = newdata(numtoadd);
|
||||
struct testkey* key = newkey(numtoadd);
|
||||
key->entry.data = data;
|
||||
lruhash_insert(table, myhash(numtoadd), &key->entry, data);
|
||||
lruhash_insert(table, myhash(numtoadd), &key->entry, data, NULL);
|
||||
ref[numtoadd] = data;
|
||||
}
|
||||
|
||||
|
|
@ -333,7 +333,7 @@ testadd_unlim(struct lruhash* table, struct testdata** ref)
|
|||
struct testdata* data = newdata(numtoadd);
|
||||
struct testkey* key = newkey(numtoadd);
|
||||
key->entry.data = data;
|
||||
lruhash_insert(table, myhash(numtoadd), &key->entry, data);
|
||||
lruhash_insert(table, myhash(numtoadd), &key->entry, data, NULL);
|
||||
if(ref)
|
||||
ref[numtoadd] = data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,8 +110,8 @@ test_short_table(struct slabhash* table)
|
|||
k->entry.data = d;
|
||||
k2->entry.data = d2;
|
||||
|
||||
slabhash_insert(table, myhash(12), &k->entry, d);
|
||||
slabhash_insert(table, myhash(14), &k2->entry, d2);
|
||||
slabhash_insert(table, myhash(12), &k->entry, d, NULL);
|
||||
slabhash_insert(table, myhash(14), &k2->entry, d2, NULL);
|
||||
|
||||
unit_assert( slabhash_lookup(table, myhash(12), k, 0) == &k->entry);
|
||||
lock_rw_unlock( &k->entry.lock );
|
||||
|
|
@ -132,7 +132,7 @@ testadd(struct slabhash* table, struct slabtestdata* ref[])
|
|||
struct slabtestdata* data = newdata(numtoadd);
|
||||
struct slabtestkey* key = newkey(numtoadd);
|
||||
key->entry.data = data;
|
||||
slabhash_insert(table, myhash(numtoadd), &key->entry, data);
|
||||
slabhash_insert(table, myhash(numtoadd), &key->entry, data, NULL);
|
||||
ref[numtoadd] = data;
|
||||
}
|
||||
|
||||
|
|
@ -219,7 +219,7 @@ testadd_unlim(struct slabhash* table, struct slabtestdata** ref)
|
|||
struct slabtestdata* data = newdata(numtoadd);
|
||||
struct slabtestkey* key = newkey(numtoadd);
|
||||
key->entry.data = data;
|
||||
slabhash_insert(table, myhash(numtoadd), &key->entry, data);
|
||||
slabhash_insert(table, myhash(numtoadd), &key->entry, data, NULL);
|
||||
if(ref)
|
||||
ref[numtoadd] = data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -208,6 +208,9 @@ alloc_special_release(struct alloc_cache* alloc, alloc_special_t* mem)
|
|||
log_assert(alloc);
|
||||
if(!mem)
|
||||
return;
|
||||
if(!alloc->super) /* superalloc needs locking */
|
||||
lock_quick_lock(&alloc->lock);
|
||||
|
||||
alloc_special_clean(mem);
|
||||
if(alloc->super && alloc->num_quar >= ALLOC_SPECIAL_MAX) {
|
||||
/* push it to the super structure */
|
||||
|
|
@ -218,6 +221,8 @@ alloc_special_release(struct alloc_cache* alloc, alloc_special_t* mem)
|
|||
alloc_set_special_next(mem, alloc->quar);
|
||||
alloc->quar = mem;
|
||||
alloc->num_quar++;
|
||||
if(!alloc->super)
|
||||
lock_quick_unlock(&alloc->lock);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -108,9 +108,7 @@ ub_rrset_key_delete(void* key, void* userdata)
|
|||
k->id = 0;
|
||||
free(k->rk.dname);
|
||||
k->rk.dname = NULL;
|
||||
lock_quick_lock(&a->lock);
|
||||
alloc_special_release(a, k);
|
||||
lock_quick_unlock(&a->lock);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -288,12 +288,13 @@ lru_touch(struct lruhash* table, struct lruhash_entry* entry)
|
|||
|
||||
void
|
||||
lruhash_insert(struct lruhash* table, hashvalue_t hash,
|
||||
struct lruhash_entry* entry, void* data)
|
||||
struct lruhash_entry* entry, void* data, void* cb_arg)
|
||||
{
|
||||
struct lruhash_bin* bin;
|
||||
struct lruhash_entry* found, *reclaimlist=NULL;
|
||||
size_t need_size;
|
||||
need_size = table->sizefunc(entry->key, data);
|
||||
if(cb_arg == NULL) cb_arg = table->cb_arg;
|
||||
|
||||
/* find bin */
|
||||
lock_quick_lock(&table->lock);
|
||||
|
|
@ -312,10 +313,10 @@ lruhash_insert(struct lruhash* table, hashvalue_t hash,
|
|||
/* if so: update data - needs a writelock */
|
||||
table->space_used += need_size -
|
||||
(*table->sizefunc)(found->key, found->data);
|
||||
(*table->delkeyfunc)(entry->key, table->cb_arg);
|
||||
(*table->delkeyfunc)(entry->key, cb_arg);
|
||||
lru_touch(table, found);
|
||||
lock_rw_wrlock(&found->lock);
|
||||
(*table->deldatafunc)(found->data, table->cb_arg);
|
||||
(*table->deldatafunc)(found->data, cb_arg);
|
||||
found->data = data;
|
||||
lock_rw_unlock(&found->lock);
|
||||
}
|
||||
|
|
@ -331,8 +332,8 @@ lruhash_insert(struct lruhash* table, hashvalue_t hash,
|
|||
struct lruhash_entry* n = reclaimlist->overflow_next;
|
||||
void* d = reclaimlist->data;
|
||||
lock_rw_unlock(&reclaimlist->lock);
|
||||
(*table->delkeyfunc)(reclaimlist->key, table->cb_arg);
|
||||
(*table->deldatafunc)(d, table->cb_arg);
|
||||
(*table->delkeyfunc)(reclaimlist->key, cb_arg);
|
||||
(*table->deldatafunc)(d, cb_arg);
|
||||
reclaimlist = n;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -246,9 +246,10 @@ void lruhash_delete(struct lruhash* table);
|
|||
* But entry->data is set to NULL before deletion, and put into
|
||||
* the existing entry. The data is then freed.
|
||||
* @param data: the data.
|
||||
* @param cb_override: if not null overrides the cb_arg for the deletefunc.
|
||||
*/
|
||||
void lruhash_insert(struct lruhash* table, hashvalue_t hash,
|
||||
struct lruhash_entry* entry, void* data);
|
||||
struct lruhash_entry* entry, void* data, void* cb_override);
|
||||
|
||||
/**
|
||||
* Lookup an entry in the hashtable.
|
||||
|
|
|
|||
|
|
@ -105,9 +105,9 @@ slab_idx(struct slabhash* sl, hashvalue_t hash)
|
|||
}
|
||||
|
||||
void slabhash_insert(struct slabhash* sl, hashvalue_t hash,
|
||||
struct lruhash_entry* entry, void* data)
|
||||
struct lruhash_entry* entry, void* data, void* arg)
|
||||
{
|
||||
lruhash_insert(sl->array[slab_idx(sl, hash)], hash, entry, data);
|
||||
lruhash_insert(sl->array[slab_idx(sl, hash)], hash, entry, data, arg);
|
||||
}
|
||||
|
||||
struct lruhash_entry* slabhash_lookup(struct slabhash* sl,
|
||||
|
|
|
|||
|
|
@ -101,9 +101,10 @@ void slabhash_delete(struct slabhash* table);
|
|||
* But entry->data is set to NULL before deletion, and put into
|
||||
* the existing entry. The data is then freed.
|
||||
* @param data: the data.
|
||||
* @param cb_override: if not NULL overrides the cb_arg for deletfunc.
|
||||
*/
|
||||
void slabhash_insert(struct slabhash* table, hashvalue_t hash,
|
||||
struct lruhash_entry* entry, void* data);
|
||||
struct lruhash_entry* entry, void* data, void* cb_override);
|
||||
|
||||
/**
|
||||
* Lookup an entry in the hashtable. Uses lruhash_lookup.
|
||||
|
|
|
|||
Loading…
Reference in a new issue