Draft: Reduce the RBTDB nodelock contention in rdataset_getownercase() and decrement_reference()

Open Ondřej Surý requested to merge 3811-lock-contention-in-the-rbtdb into main

Create a local copy of header->upper, so we can unlock the node when doing dns_name 0x20 manipulation. This shortens the time the read lock on the nodelock is held, reducing the lock contention between threads.

The detachnode() and decrement_reference() would always lock the nodelock even in cases where the node reference would be greater than 1, so no action would be taken. By reordering the contents of decrement_reference() and changing the meaning of its return value by incorporating the checks from detachnode(), we can avoid the locking when the node is referenced by more than one user.

Closes #3811

Edited by Ondřej Surý

Merge request reports