Skip to content

Commit

Permalink
MINOR: hq-interop: try to optimize copy for single HTX data block
Browse files Browse the repository at this point in the history
  • Loading branch information
a-denoyelle committed Dec 11, 2023
1 parent fb16cec commit 1fba2d0
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/hq_interop.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include <haproxy/http.h>
#include <haproxy/mux_quic.h>
#include <haproxy/qmux_http.h>
#include <haproxy/qmux_trace.h>
#include <haproxy/trace.h>

static ssize_t hq_interop_rcv_buf(struct qcs *qcs, struct buffer *b, int fin)
{
Expand Down Expand Up @@ -110,6 +112,28 @@ static size_t hq_interop_snd_buf(struct qcs *qcs, struct buffer *buf,

switch (btype) {
case HTX_BLK_DATA:
if (unlikely(fsize == count &&
!b_data(res) &&
htx_nbblks(htx) == 1 && btype == HTX_BLK_DATA)) {
void *old_area = res->area;

TRACE_DATA("perform zero-copy DATA transfer", QMUX_EV_STRM_SEND,
qcs->qcc->conn, qcs);

/* remap MUX buffer to HTX area */
*res = b_make(buf->area, buf->size,
sizeof(struct htx) + blk->addr, fsize);

/* assign old MUX area to HTX buffer. */
buf->area = old_area;
buf->data = buf->head = 0;
total += fsize;

/* update HTX to reflect its new empty status. */
*htx = *htx_from_buf(buf);
goto end;
}

if (fsize > count)
fsize = count;

Expand Down

0 comments on commit 1fba2d0

Please sign in to comment.