Use isc_queue to implement wait-free deadnodes queue
Replace the ISC_LIST based deadnodes implementation with isc_queue which is wait-free and we don't have to acquire neither the tree nor node lock to append nodes to the queue and the cleaning process can also copy (splice) the list into a local copy without acquiring the list. Currently, there's little benefit to this as we need to hold those locks anyway, but in the future as we move to RCU based implementation, this will be ready. To align the cleaning with our event loop based model, remove the hardcoded count for the node locks and use the number of the event loops instead. This way, each event loop can have its own cleaning as part of the process. Use uniform random numbers to spread the nodes evenly between the buckets (instead of hashing the domain name).
This commit is contained in:
committed by
Ondřej Surý
parent
a9b4d42346
commit
086b63f56d
@@ -39,13 +39,11 @@
|
||||
*/
|
||||
|
||||
/* test multiple calls to dns_db_getoriginnode */
|
||||
ISC_RUN_TEST_IMPL(getoriginnode) {
|
||||
ISC_LOOP_TEST_IMPL(getoriginnode) {
|
||||
dns_db_t *db = NULL;
|
||||
dns_dbnode_t *node = NULL;
|
||||
isc_result_t result;
|
||||
|
||||
UNUSED(state);
|
||||
|
||||
result = dns_db_create(mctx, ZONEDB_DEFAULT, dns_rootname,
|
||||
dns_dbtype_zone, dns_rdataclass_in, 0, NULL,
|
||||
&db);
|
||||
@@ -60,16 +58,15 @@ ISC_RUN_TEST_IMPL(getoriginnode) {
|
||||
dns_db_detachnode(db, &node);
|
||||
|
||||
dns_db_detach(&db);
|
||||
isc_loopmgr_shutdown(loopmgr);
|
||||
}
|
||||
|
||||
/* test getservestalettl and setservestalettl */
|
||||
ISC_RUN_TEST_IMPL(getsetservestalettl) {
|
||||
ISC_LOOP_TEST_IMPL(getsetservestalettl) {
|
||||
dns_db_t *db = NULL;
|
||||
isc_result_t result;
|
||||
dns_ttl_t ttl;
|
||||
|
||||
UNUSED(state);
|
||||
|
||||
result = dns_db_create(mctx, CACHEDB_DEFAULT, dns_rootname,
|
||||
dns_dbtype_cache, dns_rdataclass_in, 0, NULL,
|
||||
&db);
|
||||
@@ -90,10 +87,11 @@ ISC_RUN_TEST_IMPL(getsetservestalettl) {
|
||||
assert_int_equal(ttl, 6 * 3600);
|
||||
|
||||
dns_db_detach(&db);
|
||||
isc_loopmgr_shutdown(loopmgr);
|
||||
}
|
||||
|
||||
/* check DNS_DBFIND_STALEOK works */
|
||||
ISC_RUN_TEST_IMPL(dns_dbfind_staleok) {
|
||||
ISC_LOOP_TEST_IMPL(dns_dbfind_staleok) {
|
||||
dns_db_t *db = NULL;
|
||||
dns_dbnode_t *node = NULL;
|
||||
dns_fixedname_t example_fixed;
|
||||
@@ -107,8 +105,6 @@ ISC_RUN_TEST_IMPL(dns_dbfind_staleok) {
|
||||
isc_result_t result;
|
||||
unsigned char data[] = { 0x0a, 0x00, 0x00, 0x01 };
|
||||
|
||||
UNUSED(state);
|
||||
|
||||
result = dns_db_create(mctx, CACHEDB_DEFAULT, dns_rootname,
|
||||
dns_dbtype_cache, dns_rdataclass_in, 0, NULL,
|
||||
&db);
|
||||
@@ -243,15 +239,14 @@ ISC_RUN_TEST_IMPL(dns_dbfind_staleok) {
|
||||
}
|
||||
|
||||
dns_db_detach(&db);
|
||||
isc_loopmgr_shutdown(loopmgr);
|
||||
}
|
||||
|
||||
/* database class */
|
||||
ISC_RUN_TEST_IMPL(class) {
|
||||
ISC_LOOP_TEST_IMPL(class) {
|
||||
isc_result_t result;
|
||||
dns_db_t *db = NULL;
|
||||
|
||||
UNUSED(state);
|
||||
|
||||
result = dns_db_create(mctx, ZONEDB_DEFAULT, dns_rootname,
|
||||
dns_dbtype_zone, dns_rdataclass_in, 0, NULL,
|
||||
&db);
|
||||
@@ -264,15 +259,14 @@ ISC_RUN_TEST_IMPL(class) {
|
||||
assert_int_equal(dns_db_class(db), dns_rdataclass_in);
|
||||
|
||||
dns_db_detach(&db);
|
||||
isc_loopmgr_shutdown(loopmgr);
|
||||
}
|
||||
|
||||
/* database type */
|
||||
ISC_RUN_TEST_IMPL(dbtype) {
|
||||
ISC_LOOP_TEST_IMPL(dbtype) {
|
||||
isc_result_t result;
|
||||
dns_db_t *db = NULL;
|
||||
|
||||
UNUSED(state);
|
||||
|
||||
/* DB has zone semantics */
|
||||
result = dns_db_create(mctx, ZONEDB_DEFAULT, dns_rootname,
|
||||
dns_dbtype_zone, dns_rdataclass_in, 0, NULL,
|
||||
@@ -293,10 +287,11 @@ ISC_RUN_TEST_IMPL(dbtype) {
|
||||
assert_true(dns_db_iscache(db));
|
||||
assert_false(dns_db_iszone(db));
|
||||
dns_db_detach(&db);
|
||||
isc_loopmgr_shutdown(loopmgr);
|
||||
}
|
||||
|
||||
/* database versions */
|
||||
ISC_RUN_TEST_IMPL(version) {
|
||||
ISC_LOOP_TEST_IMPL(version) {
|
||||
isc_result_t result;
|
||||
dns_fixedname_t fname, ffound;
|
||||
dns_name_t *name, *foundname;
|
||||
@@ -305,8 +300,6 @@ ISC_RUN_TEST_IMPL(version) {
|
||||
dns_dbnode_t *node = NULL;
|
||||
dns_rdataset_t rdataset;
|
||||
|
||||
UNUSED(state);
|
||||
|
||||
result = dns_test_loaddb(&db, dns_dbtype_zone, "test.test",
|
||||
TESTS_DIR "/testdata/db/data.db");
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
@@ -360,15 +353,16 @@ ISC_RUN_TEST_IMPL(version) {
|
||||
dns_db_closeversion(db, &ver, false);
|
||||
|
||||
dns_db_detach(&db);
|
||||
isc_loopmgr_shutdown(loopmgr);
|
||||
}
|
||||
|
||||
ISC_TEST_LIST_START
|
||||
ISC_TEST_ENTRY(getoriginnode)
|
||||
ISC_TEST_ENTRY(getsetservestalettl)
|
||||
ISC_TEST_ENTRY(dns_dbfind_staleok)
|
||||
ISC_TEST_ENTRY(class)
|
||||
ISC_TEST_ENTRY(dbtype)
|
||||
ISC_TEST_ENTRY(version)
|
||||
ISC_TEST_ENTRY_CUSTOM(getoriginnode, setup_managers, teardown_managers)
|
||||
ISC_TEST_ENTRY_CUSTOM(getsetservestalettl, setup_managers, teardown_managers)
|
||||
ISC_TEST_ENTRY_CUSTOM(dns_dbfind_staleok, setup_managers, teardown_managers)
|
||||
ISC_TEST_ENTRY_CUSTOM(class, setup_managers, teardown_managers)
|
||||
ISC_TEST_ENTRY_CUSTOM(dbtype, setup_managers, teardown_managers)
|
||||
ISC_TEST_ENTRY_CUSTOM(version, setup_managers, teardown_managers)
|
||||
ISC_TEST_LIST_END
|
||||
|
||||
ISC_TEST_MAIN
|
||||
|
||||
@@ -111,7 +111,7 @@ overmempurge_addrdataset(dns_db_t *db, isc_stdtime_t now, int idx,
|
||||
dns_db_detachnode(db, &node);
|
||||
}
|
||||
|
||||
ISC_RUN_TEST_IMPL(overmempurge_bigrdata) {
|
||||
ISC_LOOP_TEST_IMPL(overmempurge_bigrdata) {
|
||||
size_t maxcache = 2097152U; /* 2MB - same as DNS_CACHE_MINSIZE */
|
||||
size_t hiwater = maxcache - (maxcache >> 3); /* borrowed from cache.c */
|
||||
size_t lowater = maxcache - (maxcache >> 2); /* ditto */
|
||||
@@ -158,9 +158,10 @@ ISC_RUN_TEST_IMPL(overmempurge_bigrdata) {
|
||||
|
||||
dns_db_detach(&db);
|
||||
isc_mem_destroy(&mctx2);
|
||||
isc_loopmgr_shutdown(loopmgr);
|
||||
}
|
||||
|
||||
ISC_RUN_TEST_IMPL(overmempurge_longname) {
|
||||
ISC_LOOP_TEST_IMPL(overmempurge_longname) {
|
||||
size_t maxcache = 2097152U; /* 2MB - same as DNS_CACHE_MINSIZE */
|
||||
size_t hiwater = maxcache - (maxcache >> 3); /* borrowed from cache.c */
|
||||
size_t lowater = maxcache - (maxcache >> 2); /* ditto */
|
||||
@@ -207,11 +208,12 @@ ISC_RUN_TEST_IMPL(overmempurge_longname) {
|
||||
|
||||
dns_db_detach(&db);
|
||||
isc_mem_destroy(&mctx2);
|
||||
isc_loopmgr_shutdown(loopmgr);
|
||||
}
|
||||
|
||||
ISC_TEST_LIST_START
|
||||
ISC_TEST_ENTRY(overmempurge_bigrdata)
|
||||
ISC_TEST_ENTRY(overmempurge_longname)
|
||||
ISC_TEST_ENTRY_CUSTOM(overmempurge_bigrdata, setup_managers, teardown_managers)
|
||||
ISC_TEST_ENTRY_CUSTOM(overmempurge_longname, setup_managers, teardown_managers)
|
||||
ISC_TEST_LIST_END
|
||||
|
||||
ISC_TEST_MAIN
|
||||
|
||||
Reference in New Issue
Block a user