mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-23 10:37:43 -04:00
Lazily allocate fetch counter
The counter in ns_client_t is used to track the maximum number of recursions in the resolver, but it is created unconditionally when starting the client and deallocated when resetting it. This commit defers the allocation of the counter till recursion needs to actually happen, speeding up authoritative workloads in perflab by 1.5~2%.
This commit is contained in:
parent
3762bf7fed
commit
20a1583661
1 changed files with 17 additions and 3 deletions
|
|
@ -863,6 +863,18 @@ query_cleanup(ns_client_t *client) {
|
||||||
query_reset(client, false);
|
query_reset(client, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
maybe_init_fetch_counter(ns_client_t *client) {
|
||||||
|
if (client->query.qc == NULL) {
|
||||||
|
/*
|
||||||
|
* Start global outgoing query count.
|
||||||
|
*/
|
||||||
|
isc_counter_create(client->manager->mctx,
|
||||||
|
client->inner.view->max_queries,
|
||||||
|
&client->query.qc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ns_query_free(ns_client_t *client) {
|
ns_query_free(ns_client_t *client) {
|
||||||
REQUIRE(NS_CLIENT_VALID(client));
|
REQUIRE(NS_CLIENT_VALID(client));
|
||||||
|
|
@ -2795,6 +2807,7 @@ fetch_and_forget(ns_client_t *client, dns_name_t *qname, dns_rdatatype_t qtype,
|
||||||
fetchp = &client->query.recursions[recursion_type].fetch;
|
fetchp = &client->query.recursions[recursion_type].fetch;
|
||||||
|
|
||||||
isc_nmhandle_attach(client->inner.handle, handlep);
|
isc_nmhandle_attach(client->inner.handle, handlep);
|
||||||
|
maybe_init_fetch_counter(client);
|
||||||
result = dns_resolver_createfetch(
|
result = dns_resolver_createfetch(
|
||||||
client->inner.view->resolver, qname, qtype, NULL, NULL, NULL,
|
client->inner.view->resolver, qname, qtype, NULL, NULL, NULL,
|
||||||
peeraddr, client->message->id, options, 0, NULL,
|
peeraddr, client->message->id, options, 0, NULL,
|
||||||
|
|
@ -6292,6 +6305,7 @@ ns_query_recurse(ns_client_t *client, dns_rdatatype_t qtype, dns_name_t *qname,
|
||||||
|
|
||||||
isc_nmhandle_attach(client->inner.handle,
|
isc_nmhandle_attach(client->inner.handle,
|
||||||
&HANDLE_RECTYPE_NORMAL(client));
|
&HANDLE_RECTYPE_NORMAL(client));
|
||||||
|
maybe_init_fetch_counter(client);
|
||||||
result = dns_resolver_createfetch(
|
result = dns_resolver_createfetch(
|
||||||
client->inner.view->resolver, qname, qtype, qdomain,
|
client->inner.view->resolver, qname, qtype, qdomain,
|
||||||
nameservers, NULL, peeraddr, client->message->id,
|
nameservers, NULL, peeraddr, client->message->id,
|
||||||
|
|
@ -11796,10 +11810,10 @@ ns_query_start(ns_client_t *client, isc_nmhandle_t *handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start global outgoing query count.
|
* Query counter will be started lazily, as it is unneeded for auth
|
||||||
|
* queries.
|
||||||
*/
|
*/
|
||||||
isc_counter_create(client->manager->mctx,
|
client->query.qc = NULL;
|
||||||
client->inner.view->max_queries, &client->query.qc);
|
|
||||||
|
|
||||||
query_setup(client, qtype);
|
query_setup(client, qtype);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue