]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: mux-h1: attempt to zero-copy Rx DATA transfers
authorWilly Tarreau <w@1wt.eu>
Wed, 5 Dec 2018 09:02:39 +0000 (10:02 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 5 Dec 2018 10:10:24 +0000 (11:10 +0100)
commit78f548f49eae95ab098a2727bc44bee2e3d81b4f
tree5c9ba8453a3210cca459887b94785223790491a5
parent45f2b89156385d2d9d0f392e575e6a8bd0f62d77
MEDIUM: mux-h1: attempt to zero-copy Rx DATA transfers

When transferring large objects, most calls are made between a full
buffer and an empty buffer. In this case there is a large opportunity
for performing zero-copy calls, with a few exceptions : the input data
must fit into the output buffer, and the data need to be properly
aligned and formated to let the HTX header fit before and the HTX
block(s) fit after.

This patch does two things :

1) it makes sure that we prepare an empty input buffer before an recv()
   call so that it appears as holding an HTX block at the front, which is
   removed afterwards. This way the data received using recv() are placed
   exactly at the target position in the input buffer for a later cast to
   HTX.

2) when receiving data in h1_process_data(), if it appears that the input
   buffer can be cast to an HTX buffer and the target buffer is empty,
   then the buffers are swapped, an HTX block is prepended in front of the
   data area, and the HTX block is appended to reference this data block.

In practice, this ensures that in most cases when transferring large files,
calls to h1_rcv_buf() are made using zero copy and a little bit of buffer
preparation (~40 bytes to be written).

Doing this adds an extra 13% performance boost on top of previous patch,
resulting in a total of 50% speed up on large transfers.
src/mux_h1.c