OPTIM: sink: don't waste time calling sink_announce_dropped() if busy

If we see that another thread is already busy trying to announce the
dropped counter, there's no point going there, so let's just skip all
that operation from sink_write() and avoid disturbing the other thread.
This results in a boost from 244 to 262k req/s.
This commit is contained in:
Willy Tarreau 2025-09-18 09:07:35 +02:00
parent 4431e3bd26
commit 08c6bbb542

View File

@ -54,8 +54,11 @@ static inline ssize_t sink_write(struct sink *sink, struct log_header hdr,
size_t maxlen, const struct ist msg[], size_t nmsg)
{
ssize_t sent = 0;
uint dropped = HA_ATOMIC_LOAD(&sink->ctx.dropped);
if (unlikely(HA_ATOMIC_LOAD(&sink->ctx.dropped) > 0)) {
if (unlikely(dropped > 0)) {
if (dropped & 1) // another thread on it.
goto fail;
sent = sink_announce_dropped(sink, hdr);
if (!sent) {