diff --git a/CHANGES b/CHANGES index 236a2057fa..baee84ed2f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +4662. [performance] Improve cache memory cleanup of zero TTL records + by putting them at the tail of LRU header lists. + [RT #45274] + 4661. [bug] A race condition could occur if a zone was reloaded while resigning, triggering a crash in rbtdb.c:closeversion(). [RT #45276] diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index e38594a6b7..0e9060ce40 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -6453,8 +6453,12 @@ add32(dns_rbtdb_t *rbtdb, dns_rbtnode_t *rbtnode, rbtdb_version_t *rbtversion, idx = newheader->node->locknum; if (IS_CACHE(rbtdb)) { - ISC_LIST_PREPEND(rbtdb->rdatasets[idx], - newheader, link); + if (ZEROTTL(newheader)) + ISC_LIST_APPEND(rbtdb->rdatasets[idx], + newheader, link); + else + ISC_LIST_PREPEND(rbtdb->rdatasets[idx], + newheader, link); INSIST(rbtdb->heaps != NULL); (void)isc_heap_insert(rbtdb->heaps[idx], newheader); @@ -6480,8 +6484,12 @@ add32(dns_rbtdb_t *rbtdb, dns_rbtnode_t *rbtnode, rbtdb_version_t *rbtversion, } idx = newheader->node->locknum; if (IS_CACHE(rbtdb)) { - ISC_LIST_PREPEND(rbtdb->rdatasets[idx], - newheader, link); + if (ZEROTTL(newheader)) + ISC_LIST_APPEND(rbtdb->rdatasets[idx], + newheader, link); + else + ISC_LIST_PREPEND(rbtdb->rdatasets[idx], + newheader, link); /* * XXXMLG We don't check the return value * here. If it fails, we will not do TTL @@ -6555,8 +6563,12 @@ add32(dns_rbtdb_t *rbtdb, dns_rbtnode_t *rbtnode, rbtdb_version_t *rbtversion, } idx = newheader->node->locknum; if (IS_CACHE(rbtdb)) { - ISC_LIST_PREPEND(rbtdb->rdatasets[idx], - newheader, link); + if (ZEROTTL(newheader)) + ISC_LIST_APPEND(rbtdb->rdatasets[idx], + newheader, link); + else + ISC_LIST_PREPEND(rbtdb->rdatasets[idx], + newheader, link); isc_heap_insert(rbtdb->heaps[idx], newheader); } else if (RESIGN(newheader)) { resign_delete(rbtdb, rbtversion, header); @@ -9569,7 +9581,9 @@ rdataset_putadditional(dns_acache_t *acache, dns_rdataset_t *rdataset, static inline isc_boolean_t need_headerupdate(rdatasetheader_t *header, isc_stdtime_t now) { if ((header->attributes & - (RDATASET_ATTR_NONEXISTENT|RDATASET_ATTR_STALE)) != 0) + (RDATASET_ATTR_NONEXISTENT | + RDATASET_ATTR_STALE | + RDATASET_ATTR_ZEROTTL)) != 0) return (ISC_FALSE); #if DNS_RBTDB_LIMITLRUUPDATE