Compare commits

...

11 Commits

Author SHA1 Message Date
Evan Hunt
7a2b054275 remove unnecessary argument to find_deepest_zonecut()
a minor bit of code refactoring - the 'node' argument wasn't
being used; it was just being treated as a local variable.
2024-09-16 17:08:34 -07:00
Evan Hunt
92157a8279 experiment: improve locking around decref()
instead of always calling decref() with a node lock, we now only
acquire the lock if the node needs to be cleaned or deleted.
2024-09-16 17:08:34 -07:00
Evan Hunt
5011360deb experiment: make header->trust atomic 2024-09-16 17:08:34 -07:00
Evan Hunt
3577c748f4 experiment: increase QP chunk size 2024-09-16 17:08:34 -07:00
Evan Hunt
5a07bea738 in findnode, use a read transaction when possible
when findnode() is called with the 'create' flag set, instead of
automatically opening a write transaction, we will now try to look up
the name with a read transaction, and only open a write transaction if
that failed.
2024-09-16 17:08:34 -07:00
Evan Hunt
c7cb8e2143 reduce node locking
some calls to bindrdataset were node-locked; this is no longer necessary.
2024-09-16 17:08:34 -07:00
Evan Hunt
63920bcaa8 access node attributes atomically
in the qpcnode struct, the .delegating, .nsec, and .dirty
members are now atomic, enabling us to avoid acquiring the
node lock when those are the only things we need to check.

also, renamed the check_zonecut() function to the more
correctly descriptive has_dname().
2024-09-16 17:08:34 -07:00
Ondřej Surý
be0f1bcdf7 compact the cache database less often
to speed up the cache, compact the database only when nodes
have been added or removed.
2024-09-16 17:08:34 -07:00
Ondřej Surý
93aa99802e add an isc_loop_rcu_barrier() for memory cleanup to finish
when adding data to the cache while over memory limits, add an
RCU barrier to ensure that memory is cleaned right away.
2024-09-16 17:08:34 -07:00
Ondřej Surý
9b79e9761b Add a function to call rcu_barrier once per loop
isc_loop_rcu_barrier() sets a flag so that rcu_barrier() will be
called at the end of the current loop tick. This allows us to minimize
time spent synchronizing between threads.
2024-09-16 17:08:34 -07:00
Evan Hunt
18ad5314cb use dns_qpmulti instead of dns_qp in the cache
replace the single-threaded dns_qp objects in the qpcache
database with dns_qpmulti and eliminate the tree lock.
2024-09-16 17:08:28 -07:00
8 changed files with 389 additions and 559 deletions

View File

@@ -75,7 +75,7 @@ struct dns_slabheader {
dns_ttl_t ttl;
dns_typepair_t type;
atomic_uint_least16_t attributes;
dns_trust_t trust;
atomic_uint_fast16_t trust;
unsigned int heap_index;
/*%<

View File

@@ -1058,7 +1058,7 @@ dns_qpmulti_memusage(dns_qpmulti_t *multi) {
dns_qp_memusage_t memusage = dns_qp_memusage(qp);
if (qp->transaction_mode == QP_UPDATE) {
if (qp->transaction_mode == QP_UPDATE && qp->usage != NULL) {
memusage.bytes -= QP_CHUNK_BYTES;
memusage.bytes += qp->usage[qp->bump].used *
sizeof(dns_qpnode_t);

View File

@@ -141,7 +141,7 @@ enum {
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
#define QP_CHUNK_LOG 7
#else
#define QP_CHUNK_LOG 10
#define QP_CHUNK_LOG 12
#endif
STATIC_ASSERT(6 <= QP_CHUNK_LOG && QP_CHUNK_LOG <= 20,

File diff suppressed because it is too large Load Diff

View File

@@ -1413,9 +1413,7 @@ static void
rdataset_settrust(dns_rdataset_t *rdataset, dns_trust_t trust) {
dns_slabheader_t *header = dns_slabheader_fromrdataset(rdataset);
dns_db_locknode(header->db, header->node, isc_rwlocktype_write);
header->trust = rdataset->trust = trust;
dns_db_unlocknode(header->db, header->node, isc_rwlocktype_write);
}
static void

View File

@@ -225,4 +225,14 @@ isc_loop_shuttingdown(isc_loop_t *loop);
*
* \li 'loop' is a valid loop and the loop tid matches the current tid.
*/
void
isc_loop_rcu_barrier(isc_loop_t *loop);
/*%<
* Triggers an rcu_barrier() call at the end of the current loop tick.
*
* Requires:
*
* \li 'loop' is a valid loop and the loop tid matches the current tid.
*/
ISC_LANG_ENDDECLS

View File

@@ -237,7 +237,7 @@ loop_init(isc_loop_t *loop, isc_loopmgr_t *loopmgr, uint32_t tid,
static void
quiescent_cb(uv_prepare_t *handle) {
UNUSED(handle);
isc_loop_t *loop = uv_handle_get_data(handle);
#if defined(RCU_QSBR)
/* safe memory reclamation */
@@ -248,6 +248,10 @@ quiescent_cb(uv_prepare_t *handle) {
#else
INSIST(!rcu_read_ongoing());
#endif
if (loop->rcu_barrier) {
rcu_barrier();
}
}
static void
@@ -693,3 +697,11 @@ isc_loop_shuttingdown(isc_loop_t *loop) {
return (loop->shuttingdown);
}
void
isc_loop_rcu_barrier(isc_loop_t *loop) {
REQUIRE(VALID_LOOP(loop));
REQUIRE(loop->tid == isc_tid());
loop->rcu_barrier = true;
}

View File

@@ -76,6 +76,8 @@ struct isc_loop {
/* safe memory reclamation */
uv_prepare_t quiescent;
bool rcu_barrier;
};
/*