[9.16] Remove the contention when pruning RBTDB nodes
In #4383 (closed), we reported:
In some older BIND 9 branches, the extra queuing overhead eliminated by
this change could be remotely exploited to cause excessive memory use.
Due to architectural shift, this branch is not vulnerable to that issue,
but applying the fix to the latter is nevertheless deemed prudent for
consistency and to make the code future-proof.
The single queue for pruning the nodes increased the lock contention to the level where cleaning up nodes from the RBTDB would take too long and the memory that the cache was using would grow indefinitely.
This commits adds bucketed prunenode lists, adds quantum of 10 items per pruning to the prune_tree() and simplifies the parent cleaning in the prune_tree() mechanism.
Instead of juggling with node locks in a cycle, cleanup the node we are just pruning and send any the parent that's also subject to the pruning to the prune tree via normal way (e.g. enqueue pruning on the parent).
This simplifies the code and also spreads the pruning load across more task loop ticks which is better for lock contention as less things run in a tight loop.
Closes #4596 (closed)
Partial and spiritual backport of !8765 (merged)