Compare commits

...

8 Commits

Author SHA1 Message Date
Witold Kręcicki
1181f9ddda Experiment: brutally remove locking in isc_result 2018-11-22 11:21:12 +00:00
Witold Kręcicki
957733d282 Experiment: make rwlocks do nothing 2018-11-22 10:49:46 +00:00
Witold Kręcicki
30b64b0b24 Experiment: quantum universally 25 2018-11-21 20:45:03 +00:00
Witold Kręcicki
1c6a542e0a Quantum 10 for network task 2018-11-21 17:03:57 +00:00
Witold Kręcicki
e22707ebdd Experiment: 'quick' dns_acl_match 2018-11-21 16:35:15 +00:00
Witold Kręcicki
c32545998b Experiment: always DNS_NAME_USEINLINE 2018-11-21 16:35:02 +00:00
Witold Kręcicki
14cf2c71e6 Experiment: disable stats 2018-11-21 16:24:46 +00:00
Witold Kręcicki
23138cd077 - isc_task_create_bound - create a task bound to specific task queue
- bind resolver tasks to queues, hashed by bucket
2018-11-21 16:24:46 +00:00
13 changed files with 88 additions and 38 deletions

View File

@@ -130,7 +130,7 @@ dns_acl_none(isc_mem_t *mctx, dns_acl_t **target) {
* If pos is false, test whether acl is set to "{ none; }"
*/
static bool
dns_acl_isanyornone(dns_acl_t *acl, bool pos)
dns_acl_isanyornone(const dns_acl_t *acl, bool pos)
{
/* Should never happen but let's be safe */
if (acl == NULL ||
@@ -157,7 +157,7 @@ dns_acl_isanyornone(dns_acl_t *acl, bool pos)
* Test whether acl is set to "{ any; }"
*/
bool
dns_acl_isany(dns_acl_t *acl)
dns_acl_isany(const dns_acl_t *acl)
{
return (dns_acl_isanyornone(acl, true));
}
@@ -166,7 +166,7 @@ dns_acl_isany(dns_acl_t *acl)
* Test whether acl is set to "{ none; }"
*/
bool
dns_acl_isnone(dns_acl_t *acl)
dns_acl_isnone(const dns_acl_t *acl)
{
return (dns_acl_isanyornone(acl, false));
}
@@ -198,6 +198,20 @@ dns_acl_match(const isc_netaddr_t *reqaddr,
REQUIRE(reqaddr != NULL);
REQUIRE(matchelt == NULL || *matchelt == NULL);
/*
* We don't care about matchelt, see if maybe that's 'any' or 'none'
* ACL to speed things up.
*/
if (matchelt == NULL) {
if (dns_acl_isany(acl)) {
*match = 1;
return (ISC_R_SUCCESS);
} else if (dns_acl_isnone(acl)) {
*match = -1;
return (ISC_R_SUCCESS);
}
}
if (env != NULL && env->match_mapped &&
addr->family == AF_INET6 &&
IN6_IS_ADDR_V4MAPPED(&addr->type.in6))

View File

@@ -462,7 +462,7 @@ dns_client_createx(isc_mem_t *mctx, isc_appctx_t *actx,
client->timermgr = timermgr;
client->task = NULL;
result = isc_task_create(client->taskmgr, 50, &client->task);
result = isc_task_create(client->taskmgr, 0, &client->task);
if (result != ISC_R_SUCCESS)
goto cleanup;

View File

@@ -2959,7 +2959,7 @@ dispatch_createudp(dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr,
}
for (i = 0; i < disp->ntasks; i++) {
disp->task[i] = NULL;
result = isc_task_create(taskmgr, 50, &disp->task[i]);
result = isc_task_create(taskmgr, 0, &disp->task[i]);
if (result != ISC_R_SUCCESS) {
while (--i >= 0) {
isc_task_shutdown(disp->task[i]);

View File

@@ -130,13 +130,13 @@ dns_acl_none(isc_mem_t *mctx, dns_acl_t **target);
*/
bool
dns_acl_isany(dns_acl_t *acl);
dns_acl_isany(const dns_acl_t *acl);
/*%<
* Test whether ACL is set to "{ any; }"
*/
bool
dns_acl_isnone(dns_acl_t *acl);
dns_acl_isnone(const dns_acl_t *acl);
/*%<
* Test whether ACL is set to "{ none; }"
*/

View File

@@ -75,6 +75,7 @@
#include <dns/types.h>
ISC_LANG_BEGINDECLS
#define DNS_NAME_USEINLINE 1
/*****
***** Labels
@@ -205,7 +206,7 @@ typedef isc_result_t (*dns_name_totextfilter_t)(isc_buffer_t *target,
***/
void
dns_name_init(dns_name_t *name, unsigned char *offsets);
dns__name_init(dns_name_t *name, unsigned char *offsets);
/*%<
* Initialize 'name'.
*
@@ -226,7 +227,7 @@ dns_name_init(dns_name_t *name, unsigned char *offsets);
*/
void
dns_name_reset(dns_name_t *name);
dns__name_reset(dns_name_t *name);
/*%<
* Reinitialize 'name'.
*
@@ -276,7 +277,7 @@ dns_name_isvalid(const dns_name_t *name);
***/
void
dns_name_setbuffer(dns_name_t *name, isc_buffer_t *buffer);
dns__name_setbuffer(dns_name_t *name, isc_buffer_t *buffer);
/*%<
* Dedicate a buffer for use with 'name'.
*
@@ -318,7 +319,7 @@ dns_name_hasbuffer(const dns_name_t *name);
***/
bool
dns_name_isabsolute(const dns_name_t *name);
dns__name_isabsolute(const dns_name_t *name);
/*%<
* Does 'name' end in the root label?
*
@@ -567,7 +568,7 @@ dns_name_matcheswildcard(const dns_name_t *name, const dns_name_t *wname);
***/
unsigned int
dns_name_countlabels(const dns_name_t *name);
dns__name_countlabels(const dns_name_t *name);
/*%<
* How many labels does 'name' have?
*
@@ -675,7 +676,7 @@ dns_name_fromregion(dns_name_t *name, const isc_region_t *r);
*/
void
dns_name_toregion(const dns_name_t *name, isc_region_t *r);
dns__name_toregion(const dns_name_t *name, isc_region_t *r);
/*%<
* Make 'r' refer to 'name'.
*
@@ -985,7 +986,7 @@ dns_name_concatenate(const dns_name_t *prefix, const dns_name_t *suffix,
*/
void
dns_name_split(const dns_name_t *name, unsigned int suffixlabels,
dns__name_split(const dns_name_t *name, unsigned int suffixlabels,
dns_name_t *prefix, dns_name_t *suffix);
/*%<
*
@@ -1385,7 +1386,7 @@ do { \
#define DNS_NAME_SPLIT(n, l, p, s) \
do { \
dns_name_t *_n = (n); \
const dns_name_t *_n = (n); \
dns_name_t *_p = (p); \
dns_name_t *_s = (s); \
unsigned int _l = (l); \
@@ -1405,6 +1406,16 @@ do { \
#define dns_name_toregion(n, r) DNS_NAME_TOREGION(n, r)
#define dns_name_split(n, l, p, s) DNS_NAME_SPLIT(n, l, p, s)
#else
#define dns_name_init(n, o) dns__name_init(n, o)
#define dns_name_reset(n) dns__name_reset(n)
#define dns_name_setbuffer(n, b) dns__name_setbuffer(n, b)
#define dns_name_countlabels(n) dns__name_countlabels(n)
#define dns_name_isabsolute(n) dns__name_isabsolute(n)
#define dns_name_toregion(n, r) dns__name_toregion(n, r)
#define dns_name_split(n, l, p, s) dns__name_split(n, l, p, s)
#endif /* DNS_NAME_USEINLINE */
#endif /* DNS_NAME_H */

View File

@@ -176,7 +176,7 @@ set_offsets(const dns_name_t *name, unsigned char *offsets,
dns_name_t *set_name);
void
dns_name_init(dns_name_t *name, unsigned char *offsets) {
dns__name_init(dns_name_t *name, unsigned char *offsets) {
/*
* Initialize 'name'.
*/
@@ -184,7 +184,7 @@ dns_name_init(dns_name_t *name, unsigned char *offsets) {
}
void
dns_name_reset(dns_name_t *name) {
dns__name_reset(dns_name_t *name) {
REQUIRE(VALID_NAME(name));
REQUIRE(BINDABLE(name));
@@ -250,7 +250,7 @@ dns_name_isvalid(const dns_name_t *name) {
}
void
dns_name_setbuffer(dns_name_t *name, isc_buffer_t *buffer) {
dns__name_setbuffer(dns_name_t *name, isc_buffer_t *buffer) {
/*
* Dedicate a buffer for use with 'name'.
*/
@@ -277,7 +277,7 @@ dns_name_hasbuffer(const dns_name_t *name) {
}
bool
dns_name_isabsolute(const dns_name_t *name) {
dns__name_isabsolute(const dns_name_t *name) {
/*
* Does 'name' end in the root label?
@@ -849,7 +849,7 @@ dns_name_matcheswildcard(const dns_name_t *name, const dns_name_t *wname) {
}
unsigned int
dns_name_countlabels(const dns_name_t *name) {
dns__name_countlabels(const dns_name_t *name) {
/*
* How many labels does 'name' have?
*/
@@ -1017,7 +1017,7 @@ dns_name_fromregion(dns_name_t *name, const isc_region_t *r) {
}
void
dns_name_toregion(const dns_name_t *name, isc_region_t *r) {
dns__name_toregion(const dns_name_t *name, isc_region_t *r) {
/*
* Make 'r' refer to 'name'.
*/
@@ -2130,7 +2130,7 @@ dns_name_concatenate(const dns_name_t *prefix, const dns_name_t *suffix,
}
void
dns_name_split(const dns_name_t *name, unsigned int suffixlabels,
dns__name_split(const dns_name_t *name, unsigned int suffixlabels,
dns_name_t *prefix, dns_name_t *suffix)
{

View File

@@ -4382,8 +4382,8 @@ fctx_shutdown(fetchctx_t *fctx) {
*/
if (fctx->state != fetchstate_init) {
cevent = &fctx->control_event;
isc_task_send(fctx->res->buckets[fctx->bucketnum].task,
&cevent);
isc_task_sendto(fctx->res->buckets[fctx->bucketnum].task,
&cevent, fctx->bucketnum);
}
}
@@ -9925,7 +9925,7 @@ dns_resolver_create(dns_view_t *view,
if (result != ISC_R_SUCCESS)
goto cleanup_buckets;
res->buckets[i].task = NULL;
result = isc_task_create(taskmgr, 0, &res->buckets[i].task);
result = isc_task_create_bound(taskmgr, 0, &res->buckets[i].task, i);
if (result != ISC_R_SUCCESS) {
DESTROYLOCK(&res->buckets[i].lock);
goto cleanup_buckets;

View File

@@ -136,6 +136,10 @@ struct isc_task {
isc_result_t
isc_task_create(isc_taskmgr_t *manager, unsigned int quantum,
isc_task_t **taskp);
isc_result_t
isc_task_create_bound(isc_taskmgr_t *manager, unsigned int quantum,
isc_task_t **taskp, int threadid);
/*%<
* Create a task.
*

View File

@@ -257,8 +257,6 @@ isc_result_tomany_helper(resulttable_list_t *tables, isc_result_t result) {
initialize();
LOCK(&lock);
text = NULL;
for (table = ISC_LIST_HEAD(*tables);
table != NULL;
@@ -280,8 +278,6 @@ isc_result_tomany_helper(resulttable_list_t *tables, isc_result_t result) {
text = isc_msgcat_get(isc_msgcat, ISC_RESULT_UNAVAILABLESET,
1, "(result code text not available)");
UNLOCK(&lock);
return (text);
}

View File

@@ -236,6 +236,7 @@ isc_rwlock_destroy(isc_rwlock_t *rwl) {
static isc_result_t
isc__rwlock_lock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
return (ISC_R_SUCCESS);
int32_t cntflag;
REQUIRE(VALID_RWLOCK(rwl));
@@ -357,6 +358,7 @@ isc__rwlock_lock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
isc_result_t
isc_rwlock_lock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
return (ISC_R_SUCCESS);
int32_t cnt = 0;
int32_t max_cnt = rwl->spins * 2 + 10;
isc_result_t result = ISC_R_SUCCESS;
@@ -379,6 +381,7 @@ isc_rwlock_lock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
isc_result_t
isc_rwlock_trylock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
return (ISC_R_SUCCESS);
int32_t cntflag;
REQUIRE(VALID_RWLOCK(rwl));
@@ -450,6 +453,7 @@ isc_rwlock_trylock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
isc_result_t
isc_rwlock_tryupgrade(isc_rwlock_t *rwl) {
return (ISC_R_SUCCESS);
REQUIRE(VALID_RWLOCK(rwl));
{
@@ -483,6 +487,7 @@ isc_rwlock_tryupgrade(isc_rwlock_t *rwl) {
void
isc_rwlock_downgrade(isc_rwlock_t *rwl) {
return;
int32_t prev_readers;
REQUIRE(VALID_RWLOCK(rwl));
@@ -511,6 +516,7 @@ isc_rwlock_downgrade(isc_rwlock_t *rwl) {
isc_result_t
isc_rwlock_unlock(isc_rwlock_t *rwl, isc_rwlocktype_t type) {
return (ISC_R_SUCCESS);
int32_t prev_cnt;
REQUIRE(VALID_RWLOCK(rwl));

View File

@@ -165,6 +165,7 @@ isc_stats_create(isc_mem_t *mctx, isc_stats_t **statsp, int ncounters) {
void
isc_stats_increment(isc_stats_t *stats, isc_statscounter_t counter) {
return;
REQUIRE(ISC_STATS_VALID(stats));
REQUIRE(counter < stats->ncounters);
@@ -174,6 +175,7 @@ isc_stats_increment(isc_stats_t *stats, isc_statscounter_t counter) {
void
isc_stats_decrement(isc_stats_t *stats, isc_statscounter_t counter) {
return;
REQUIRE(ISC_STATS_VALID(stats));
REQUIRE(counter < stats->ncounters);

View File

@@ -104,6 +104,7 @@ struct isc__task {
char name[16];
void * tag;
unsigned int threadid;
bool bound;
/* Locked by task manager lock. */
LINK(isc__task_t) link;
LINK(isc__task_t) ready_link;
@@ -171,8 +172,7 @@ void
isc__taskmgr_resume(isc_taskmgr_t *manager0);
#define DEFAULT_TASKMGR_QUANTUM 10
#define DEFAULT_DEFAULT_QUANTUM 5
#define DEFAULT_DEFAULT_QUANTUM 25
#define FINISHED(m) ((m)->exiting && EMPTY((m)->tasks))
/*%
@@ -243,7 +243,14 @@ task_finished(isc__task_t *task) {
isc_result_t
isc_task_create(isc_taskmgr_t *manager0, unsigned int quantum,
isc_task_t **taskp)
isc_task_t **taskp)
{
return (isc_task_create_bound(manager0, quantum, taskp, -1));
}
isc_result_t
isc_task_create_bound(isc_taskmgr_t *manager0, unsigned int quantum,
isc_task_t **taskp, int threadid)
{
isc__taskmgr_t *manager = (isc__taskmgr_t *)manager0;
isc__task_t *task;
@@ -258,9 +265,15 @@ isc_task_create(isc_taskmgr_t *manager0, unsigned int quantum,
return (ISC_R_NOMEMORY);
XTRACE("isc_task_create");
task->manager = manager;
task->threadid = atomic_fetch_add_explicit(&manager->curq, 1,
memory_order_relaxed)
% manager->workers;
if (threadid == -1) {
task->bound = false;
task->threadid = atomic_fetch_add_explicit(&manager->curq, 1,
memory_order_relaxed)
% manager->workers;
} else {
task->bound = true;
task->threadid = threadid % manager->workers;
}
result = isc_mutex_init(&task->lock);
if (result != ISC_R_SUCCESS) {
isc_mem_put(manager->mctx, task, sizeof(*task));
@@ -494,7 +507,9 @@ isc_task_sendto(isc_task_t *task0, isc_event_t **eventp, int c) {
REQUIRE(VALID_TASK(task));
XTRACE("isc_task_send");
if (c < 0) {
if (task->bound) {
c = task->threadid;
} else if (c < 0) {
c = atomic_fetch_add_explicit(&task->manager->curq, 1,
memory_order_relaxed);
}
@@ -544,7 +559,9 @@ isc_task_sendtoanddetach(isc_task_t **taskp, isc_event_t **eventp, int c) {
REQUIRE(VALID_TASK(task));
XTRACE("isc_task_sendanddetach");
if (c < 0) {
if (task->bound) {
c = task->threadid;
} else if (c < 0) {
c = atomic_fetch_add_explicit(&task->manager->curq, 1,
memory_order_relaxed);
}

View File

@@ -2964,7 +2964,7 @@ client_create(ns_clientmgr_t *manager, ns_client_t **clientp) {
ns_server_attach(manager->sctx, &client->sctx);
client->task = NULL;
result = isc_task_create(manager->taskmgr, 50, &client->task);
result = isc_task_create(manager->taskmgr, 0, &client->task);
if (result != ISC_R_SUCCESS)
goto cleanup_client;
isc_task_setname(client->task, "client", client);