]> git.ipfire.org Git - thirdparty/bind9.git/commit
Replace per-zone lock buckets with global buckets
authorAlessio Podda <alessio@isc.org>
Wed, 7 May 2025 12:52:11 +0000 (14:52 +0200)
committerAlessio Podda <alessio@isc.org>
Wed, 9 Jul 2025 13:27:38 +0000 (15:27 +0200)
commit25daa047d4a34b9515fa5bc3e55c18ce6934aa30
tree9f25e2487e9c777705bf21b70f70f5c796b5edd7
parent512f1d3005cb7e434ddbfddf58c852a8091581cb
Replace per-zone lock buckets with global buckets

Qpzone employs a locking strategy where rwlocks are grouped into
buckets, and each zone gets 17 buckets.
This strategy is suboptimal in two ways:
 - If named is serving a single zone or a zone is the majority of the
   traffic, this strategy pretty much guarantees contention when using
   more than a dozen threads.
 - If named is serving many small zones, it causes substantial memory
   usage.

This commit switches the locking to a global table initialized at start
time. This should have three effects:
 - Performance should improve in the single zone case, since now we are
   selecting from a bigger pool of locks.
 - Memory consumption should go down significantly in the many zone
   cases.
 - Performance should not degrade substantially in the many zone cases.
   The reason for this is that, while we could have substantially more
   zones than locks, we can query/edit only O(num threads) at the same
   time. So by making the global table much bigger than the expected
   number of threads, we can limit contention.
lib/dns/lib.c
lib/dns/qpzone.c
lib/dns/qpzone_p.h
tests/dns/qpzone_test.c