OPTIM: queue: don't call pendconn_unlink() when the pendconn is not queued
authorWilly Tarreau <w@1wt.eu>
Wed, 21 Oct 2020 09:04:08 +0000 (11:04 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 22 Oct 2020 15:32:28 +0000 (17:32 +0200)
commitb7ba1d901174cb1193033f7d967987ef74e89856
treedda1c6d42e8fd2941488b75e0a720acb5507c791
parent5503908bdc4326e2c822fc1eadddc8c18843f4c1
OPTIM: queue: don't call pendconn_unlink() when the pendconn is not queued

On connection error processing, we can see massive storms of calls to
pendconn_cond_unlink() to release a possible place in the queue. For
example, in issue #908, on average half of the threads are caught in
this function via back_try_conn_req() consecutive to a synchronous
error. However we wait until grabbing the lock to know if the pendconn
is effectively in a queue, which is expensive for many cases. We know
the transition may only happen from in-queue to out-of-queue so it's safe
to first run a preliminary check to see if it's worth going further. This
will allow to avoid the cost of locking for most requests. This should
not change anything for those completing correctly as they're already
run through pendconn_free() which doesn't call pendconn_cond_unlink()
unless deemed necessary.
include/haproxy/queue.h