Redesign RBTDB cache cleaning
Current cache cleaning has two mechanisms in the RBTDB:
- TTL-based cleaning implemented using
isc_heap
unit - LRU-based cleaning implemented using
isc_list
unit
TTL-based cleaning
The TTL-based cleaning is just a priority queue that uses TTL (header->rdh_ttl
) to sort the nodes. There are two triggers:
Cleaning when adding data
This is triggered during adding new rdataset to the cache - the node is write locked, the tree is locked only when we are adding delegation type, adding to the auxiliary NSEC tree or the cache is overmem.
If we are overmem, the overmem cleaning is triggered (see below).
In all cases, we lookup the top element from the heap (with lowest TTL) and call expire_header()
on header that has TTL (adjusted with stale-TTL) lower than now (adjusted by 5 minutes (RBTDB_VIRTUAL
).
Cleaning when overmem
The overmem purge is also called when adding new data and it tries to purge at most two headers from a bucket that we are not currently in.
First, it does single TTL-based cleaning - only the now
time is adjusted by 5 minutes (RBTDB_VIRTUAL
) and then in goes to LRU-based cleaning.
If it doesn't find two headers in the current bucket it goes to the next bucket.
Not-really an expire
We also "expire", but not really remove headers from add32()
with following comment /* The new rdataset is better. Expire the ncache entry. */
; but it only does mark header as ancient, and sets the TTL to 0 - and in one more place when rbtversion == 0
.