]> git.ipfire.org Git - thirdparty/bind9.git/commit
Optimize database decref by avoiding locking with refs > 1
authorJINMEI Tatuya <jtatuya@infoblox.com>
Sat, 18 Jan 2025 00:54:19 +0000 (16:54 -0800)
committerOndřej Surý <ondrej@isc.org>
Wed, 22 Jan 2025 13:31:09 +0000 (14:31 +0100)
commit065ffb2eb80b68c5df37eae6e1a114e41ceb586d
treece863a2a27576aaec45e4074fc6e923eb59d58e8
parent57187b2c4f4be65af0f4f11ee625e353405de952
Optimize database decref by avoiding locking with refs > 1

Previously, this function always acquires a node write lock if it
might need node cleanup in case the reference decrements to 0.  In
fact, the lock is unnecessary if the reference is larger than 1 and it
can be optimized as an "easy" case. This optimization could even be
"necessary". In some extreme cases, many worker threads could repeat
acquring and releasing the reference on the same node, resulting in
severe lock contention for nothing (as the ref wouldn't decrement to 0
in most cases). This change would prevent noticeable performance
drop like query timeout for such cases.

Co-authored-by: JINMEI Tatuya <jtatuya@infoblox.com>
Co-authored-by: Ondřej Surý <ondrej@isc.org>
(cherry picked from commit 7f4471594db157b61218ee6377e6ba0887092a41)
lib/dns/rbtdb.c