Skip to content

Replace some ADB entry locking with atomics to reduce ADB contention

Ondřej Surý requested to merge 4326-remove-locking-from-copy_namehook_lists into main

Use atomics on couple of ADB entry members (.srtt, .flags, .expires, and .lastage) to remove ADB entry locking from couple of hot spots. The most prominent place is copy_namehook_lists() that gets called under ADB name lock and if the namehook list is long it acquires-releases quite a few ADB entry locks. Changing those ADB entry members to atomics allowed us to new_adbaddrinfo() not require locked ADB entry and since adbentry_overquota() already used atomics and handling lame information was dropped in the previous commit, we could not make the copy_namehook_lists() lockless.

The other hotspot is dns_adb_adjustsrtt() and dns_adb_agesrtt() that can now use atomics because .srtt is already atomic_uint.

And the last place that could now use atomics is dns_adb_changeflags().

This doesn't closes #4326 (closed) as there's more stuff to do.

Edited by Ondřej Surý

Merge request reports