From 681e286ada519dca5d19a16911fcf352c54b1bc3 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Fri, 28 Jul 2017 00:14:08 -0700 Subject: [PATCH] [v9_9] Maintain ZEROTTL cache entries at the tail of the LRU lists 4662. [performance] Improve cache memory cleanup of zero TTL records by putting them at the tail of LRU header lists. [RT #45274] (cherry picked from commit e92415521184cf03e8c2a340b845d8990e2ec539) --- CHANGES | 4 ++++ lib/dns/rbtdb.c | 28 +++++++++++++++++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) 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