]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: pipe/thread: reduce the locking overhead
authorWilly Tarreau <w@1wt.eu>
Wed, 29 Jan 2020 09:41:34 +0000 (10:41 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 29 Jan 2020 09:44:00 +0000 (10:44 +0100)
commita945cfdfe05cd0d3b5898d8f650e03962643275d
tree3a34ad369f9db3b20f3ffdcf24fee95dff36ce55
parenta25a19fdee548241165b59af94c68d1b5b083bee
MEDIUM: pipe/thread: reduce the locking overhead

In a quick test involving splicing, we can see that get_pipe() and
put_pipe() together consume up to 12% of the CPU. That's not surprizing
considering how much work is performed under the lock, including the
pipe struct allocation, the pipe creation and its initialization. Same
for releasing, we don't need a lock there to call close() nor to free
to the pool.

Changing this alone was enough to cut the overhead in half. A better
approach should consist in having a per-thread pipe cache, which will
also help keep pages hot in the CPU caches.
src/pipe.c