mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 15:17:01 +02:00
MINOR: mux-h2: copy small data blocks more often and reduce the number of pauses
We tend to refrain from sending data a bit too much in the H2 mux : whenever there are pending data in the buffer and we try to copy something larger than 1/4 of the buffer we prefer to pause. This is suboptimal for medium-sized objects which have to send their headers and later their data. This patch slightly changes this by allowing a copy of a large block if it fits at once and if the realign cost is small, i.e. the pending data are small or the block fits in the contiguous area. Depending on the object size this measurably improves the download performance by between 1 and 10%, and possibly lowers the transfer latency for medium objects.
This commit is contained in:
parent
fd8bd4521a
commit
8ab128c06a
14
src/mux_h2.c
14
src/mux_h2.c
@ -4733,13 +4733,17 @@ static size_t h2s_htx_frt_make_resp_data(struct h2s *h2s, struct buffer *buf, si
|
||||
void *old_area = h2c->mbuf.area;
|
||||
|
||||
if (b_data(&h2c->mbuf)) {
|
||||
/* too bad there are data left there. If we have less
|
||||
* than 1/4 of the mbuf's size and everything fits,
|
||||
* we'll perform a copy anyway. Otherwise we'll pretend
|
||||
* the mbuf is full and wait.
|
||||
/* Too bad there are data left there. We're willing to memcpy/memmove
|
||||
* up to 1/4 of the buffer, which means that it's OK to copy a large
|
||||
* frame into a buffer containing few data if it needs to be realigned,
|
||||
* and that it's also OK to copy few data without realigning. Otherwise
|
||||
* we'll pretend the mbuf is full and wait for it to become empty.
|
||||
*/
|
||||
if (fsize <= b_size(&h2c->mbuf) / 4 && fsize + 9 <= b_room(&h2c->mbuf))
|
||||
if (fsize + 9 <= b_room(&h2c->mbuf) &&
|
||||
(b_data(&h2c->mbuf) <= b_size(&h2c->mbuf) / 4 ||
|
||||
(fsize <= b_size(&h2c->mbuf) / 4 && fsize + 9 <= b_contig_space(&h2c->mbuf))))
|
||||
goto copy;
|
||||
|
||||
h2c->flags |= H2_CF_MUX_MFULL;
|
||||
h2s->flags |= H2_SF_BLK_MROOM;
|
||||
goto end;
|
||||
|
Loading…
Reference in New Issue
Block a user