MINOR: tools: use only opportunistic symbols resolution
authorWilly Tarreau <w@1wt.eu>
Fri, 21 Feb 2025 14:01:13 +0000 (15:01 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 13 Mar 2025 15:03:40 +0000 (16:03 +0100)
commit9882abeada0eef928ebdb9f7377e13bafaceb564
tree27ee224ac408cf0df5c34f1f410419c01b764902
parent5f4fe64ea7d250f0927e3f250515319b3588ae10
MINOR: tools: use only opportunistic symbols resolution

As seen in issue #2861, dladdr_and_size() an be quite expensive and
will often hold a mutex in the underlying library. It becomes a real
problem when issuing lots of "show threads" or wdt warnings in parallel
because threads will queue up waiting for each other to finish, adding
to their existing latency that possibly caused the warning in the first
place.

Here we're taking a different approach. If the thread is not isolated
and not panicking, it's doing unimportant stuff like showing threads
or warnings. In this case we try to grab a lock, and if we fail because
another thread is already there, we just pretend we cannot resolve the
symbol. This is not critical because then we fall back to the already
used case which consists in writing "main+<offset>". In practice this
will almost never happen except in bad situations which could have
otherwise degenerated.

(cherry picked from commit eb41d768f954d5c7360fd19ec69f9d707b900532)
Signed-off-by: Willy Tarreau <w@1wt.eu>
src/tools.c