]> git.ipfire.org Git - thirdparty/haproxy.git/commit
OPTIM: channel: speed up co_getline()'s search of the end of line
authorWilly Tarreau <w@1wt.eu>
Mon, 30 Sep 2024 09:19:20 +0000 (11:19 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 30 Sep 2024 09:36:39 +0000 (11:36 +0200)
commit11051ed9c7fc525fa635983846c765c6302f2150
tree27c5b65de0e83229508d662183506858b114c415
parent7caf073faa6962de15a18dadcaf200df95ce7889
OPTIM: channel: speed up co_getline()'s search of the end of line

Previously, co_getline() was essentially used for occasional parsing
in peers's banner or Lua, so it could afford to read one character at
a time. However now it's also used on the TCP log path, where it can
consume up to 40% CPU as mentioned in GH issue #2731. Let's speed it
up by using memchr() to look for the LF, and copying the data at once
using memcpy().

Previously it would take 2.44s to consume 1 GB of log on a single
thread of a Core i7-8650U, now it takes 1.56s (-36%).
src/channel.c