]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: stick-table: use a distinct lock for the updates tree
authorWilly Tarreau <w@1wt.eu>
Sat, 27 May 2023 17:55:15 +0000 (17:55 +0000)
committerWilly Tarreau <w@1wt.eu>
Fri, 11 Aug 2023 17:03:35 +0000 (19:03 +0200)
commit87e072eea578211005a93add43953ba9fd906a14
treebf81d31e8d773940a3bbd176512d68fd309f9f53
parent29982ea769432f78666b19f3ae330b8a15ddeb08
MEDIUM: stick-table: use a distinct lock for the updates tree

Updating an entry in the updates tree is currently performed under the
table's write lock, which causes huge contention with other accesses
such as lookups and free. Aside the updates tree, the update,
localupdate and commitupdate variables, nothing is manipulated, so
let's create a distinct lock (updt_lock) to protect these together
to remove this contention. It required to add an extra lock in the
few places where we delete the update (though only if we're really
going to delete it) to protect the tree. This is very convenient
because now peer_send_teachmsgs() only needs to take this read lock,
and there is very little contention left on the stick-table.

With this alone, the performance jumped from 614k to 1140k/s on a
80-thread machine with a peers section! Stick-table updates with
no peers however now has to stand two locks and slightly regressed
from 4.0-4.1M/s to 3.9-4.0. This is fairly minimal compared to the
significant unlocking of the peers updates and considered totally
acceptable.
include/haproxy/stick_table-t.h
src/peers.c
src/stick_table.c