compact the cache database less often

to speed up the cache, compact the database only when nodes
have been added or removed.
This commit is contained in:
Ondřej Surý
2024-06-07 17:24:45 -07:00
committed by Evan Hunt
parent 929fb51612
commit 6f8a75e6e1
+14 -3
View File
@@ -283,6 +283,7 @@ typedef struct {
*/
typedef struct {
bool writing;
bool compact;
dns_qpread_t qpr;
dns_qp_t *tree;
dns_qp_t *nsec;
@@ -553,6 +554,8 @@ delete_node(qpcnode_t *node, dbmod_t *modctx) {
isc_result_t result = ISC_R_UNEXPECTED;
modctx->compact = true;
if (isc_log_wouldlog(dns_lctx, ISC_LOG_DEBUG(1))) {
char printname[DNS_NAME_FORMATSIZE];
dns_name_format(&node->name, printname, sizeof(printname));
@@ -2649,6 +2652,7 @@ findnode(dns_db_t *db, const dns_name_t *name, bool create,
result = dns_qp_insert(modctx.tree, node, 0);
INSIST(result == ISC_R_SUCCESS);
qpcnode_unref(node);
modctx.compact = true;
}
reactivate_node(qpdb, node, &modctx DNS__DB_FLARG_PASS);
@@ -2657,7 +2661,9 @@ findnode(dns_db_t *db, const dns_name_t *name, bool create,
cleanup:
if (create) {
dns_qp_compact(modctx.tree, DNS_QPGC_MAYBE);
if (modctx.compact) {
dns_qp_compact(modctx.tree, DNS_QPGC_MAYBE);
}
dns_qpmulti_commit(qpdb->tree, &modctx.tree);
} else {
dns_qpread_destroy(qpdb->tree, &modctx.qpr);
@@ -3433,6 +3439,7 @@ addrdataset(dns_db_t *db, dns_dbnode_t *node,
result = dns_qp_insert(modctx.nsec, nsecnode, 0);
INSIST(result == ISC_R_SUCCESS);
qpcnode_detach(&nsecnode);
modctx.compact = true;
}
qpnode->nsec = DNS_DB_NSEC_HAS_NSEC;
}
@@ -3449,10 +3456,14 @@ addrdataset(dns_db_t *db, dns_dbnode_t *node,
NODE_UNLOCK(&qpdb->node_locks[qpnode->locknum].lock, &nlocktype);
if (writing) {
dns_qp_compact(modctx.tree, DNS_QPGC_MAYBE);
if (modctx.compact) {
dns_qp_compact(modctx.tree, DNS_QPGC_MAYBE);
}
dns_qpmulti_commit(qpdb->tree, &modctx.tree);
if (newnsec) {
dns_qp_compact(modctx.nsec, DNS_QPGC_MAYBE);
if (modctx.compact) {
dns_qp_compact(modctx.nsec, DNS_QPGC_MAYBE);
}
dns_qpmulti_commit(qpdb->nsec, &modctx.nsec);
}
} else {