Skip to content

Commit

Permalink
MINOR: mux-quic: realign Tx buffer if possible
Browse files Browse the repository at this point in the history
A major reorganization of QUIC MUX sending has been implemented. Now
data transfer occur over a single QCS buffer. This has improve
performance but at the cost of restrictions on snd_buf. Indeed, buffer
instances are now shared from stream callback snd_buf up to quic-conn
layer.

As such, snd_buf cannot manipulate freely already present data buffer.
In particular, realign has been completely removed by the previous
patches.

This commit reintroduces a partial realign support. This is only done if
the buffer contains only unsent data, via a new MUX function
qcc_realign_stream_txbuf() which is called during snd_buf.
  • Loading branch information
a-denoyelle committed Jan 31, 2024
1 parent 4513787 commit 4b5f557
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions include/haproxy/mux_quic.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ int qcc_notify_buf(struct qcc *qcc);

struct buffer *qcc_get_stream_rxbuf(struct qcs *qcs);
struct buffer *qcc_get_stream_txbuf(struct qcs *qcs, int *err);
int qcc_realign_stream_txbuf(const struct qcs *qcs, struct buffer *out);
int qcc_release_stream_txbuf(struct qcs *qcs);
int qcc_stream_can_send(const struct qcs *qcs);
void qcc_reset_stream(struct qcs *qcs, int err);
Expand Down
17 changes: 14 additions & 3 deletions src/h3.c
Original file line number Diff line number Diff line change
Expand Up @@ -1900,8 +1900,14 @@ static int h3_resp_data_send(struct qcs *qcs, struct htx *htx,
if (fsize > count)
fsize = count;

/* TODO buffer can be realign only if no data waiting for ACK. */
outbuf = b_make(b_tail(res), b_contig_space(res), 0, 0);
while (1) {
b_reset(&outbuf);
outbuf = b_make(b_tail(res), b_contig_space(res), 0, 0);
if (b_size(&outbuf) > hsize || !b_space_wraps(res))
break;
if (qcc_realign_stream_txbuf(qcs, res))
break;
}

/* Not enough room for headers and at least one data byte, try to
* release the current buffer and allocate a new one. If not possible,
Expand Down Expand Up @@ -2082,7 +2088,12 @@ static size_t h3_nego_ff(struct qcs *qcs, size_t count)

/* h3 DATA headers : 1-byte frame type + varint frame length */
hsize = 1 + QUIC_VARINT_MAX_SIZE;
/* TODO buffer can be realign only if no data waiting for ACK. */
while (1) {
if (b_contig_space(res) >= hsize || !b_space_wraps(res))
break;
if (qcc_realign_stream_txbuf(qcs, res))
break;
}

/* Not enough room for headers and at least one data byte, block the
* stream. It is expected that the stream connector layer will subscribe
Expand Down
15 changes: 15 additions & 0 deletions src/mux_quic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,21 @@ static uint64_t qcs_prep_bytes(const struct qcs *qcs)
return b_data(out) - diff;
}

/* Try to realign <out> buffer for <qcs> stream. This is done only if there is
* no data waiting for ACK.
*
* Returns 0 if realign was performed else non-zero.
*/
int qcc_realign_stream_txbuf(const struct qcs *qcs, struct buffer *out)
{
if (qcs_prep_bytes(qcs) == b_data(out)) {
b_slow_realign(out, trash.area, b_data(out));
return 0;
}

return 1;
}

/* Release the current <qcs> Tx buffer. This is useful if space left is not
* enough anymore. A new instance can then be allocated to continue sending.
*
Expand Down

0 comments on commit 4b5f557

Please sign in to comment.