]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: resolvers: make the process_resolvers() task single-threaded
authorWilly Tarreau <w@1wt.eu>
Wed, 10 Sep 2025 14:51:14 +0000 (16:51 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 10 Sep 2025 14:51:14 +0000 (16:51 +0200)
commit2ce5e0edcce03d648a443c1f84307e3bdc7a2710
treea9c297f6592efd4042d901899f533190a74cf9dc
parentd624aceaef5ddf09cc8869990ffb4033ad93a452
MEDIUM: resolvers: make the process_resolvers() task single-threaded

This task is sometimes caught triggering the watchdog while waiting for
the infamous resolvers lock, or the scheduler's wait queue lock in
task_queue(). Both are caused by its multi-threaded capability. The
task may indeed start on a thread that's different from the one that
is currently receiving a response and that holds the resolvers lock,
and when being queued back, it requires to lock the wait queue. Both
problems disappear when sticking it to a single thread. But for configs
running multiple resolvers sections, it would be suboptimal to run them
all on the same thread. In order to avoid this, we implement a counter
in the resolvers_finalize_config() section that rotates the thread for
each resolvers section.

This was sufficient to further improve the performance here, making the
CPU usage drop to about 7% (from 11 previously or 38 initially) and not
showing any resolvers lock contention anymore in perf top output.

The change was kept fairly minimal to permit a backport once enough
testing is conducted on it. It could address a significant part of
the trouble reported by Felipe in GH issue #3101.
src/resolvers.c