]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
OPTIM: mux-quic: delay FE sedesc alloc to stream creation
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 20 Nov 2025 17:15:21 +0000 (18:15 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 21 Nov 2025 09:34:08 +0000 (10:34 +0100)
On frontend side, a stream-endpoint is allocated on every qcs_new()
invokation. However, this is only used for bidirectional request
streams.

This patch delays stream-endpoint allocation to qcs_attach_sc(), just
prior the instantiation of the upper stream object. This does not bring
any behavior change but is a nice optimization.

src/mux_quic.c

index 947c1060906b34f17c8cf224c6c1bb39eeea183e..2d6fb25b8b67e2aec1e1ffa98dc9dc891cf353dd 100644 (file)
@@ -194,19 +194,6 @@ static struct qcs *qcs_new(struct qcc *qcc, uint64_t id, enum qcs_type type)
        tot_time_reset(&qcs->timer.fctl);
        tot_time_start(&qcs->timer.base);
 
-       if (!conn_is_back(conn)) {
-               qcs->sd = sedesc_new();
-               if (!qcs->sd)
-                       goto err;
-               qcs->sd->se   = qcs;
-               qcs->sd->conn = qcc->conn;
-               se_fl_set(qcs->sd, SE_FL_T_MUX | SE_FL_ORPHAN | SE_FL_NOT_FIRST);
-               se_expect_no_data(qcs->sd);
-
-               if (!(global.tune.no_zero_copy_fwd & NO_ZERO_COPY_FWD_QUIC_SND))
-                       se_fl_set(qcs->sd, SE_FL_MAY_FASTFWD_CONS);
-       }
-
        /* Allocate transport layer stream descriptor. Only needed for TX. */
        if (!quic_stream_is_uni(id) || !quic_stream_is_remote(qcc, id)) {
                struct quic_conn *qc = qcc->conn->handle.qc;
@@ -947,6 +934,20 @@ int qcs_attach_sc(struct qcs *qcs, struct buffer *buf, char fin)
        /* TODO duplicated from mux_h2 */
        sess->t_idle = ns_to_ms(now_ns - sess->accept_ts) - sess->t_handshake;
 
+       /* first create the stream endpoint descriptor */
+       qcs->sd = sedesc_new();
+       if (!qcs->sd) {
+               TRACE_DEVEL("leaving on error", QMUX_EV_STRM_RECV, qcc->conn, qcs);
+               return -1;
+       }
+       qcs->sd->se   = qcs;
+       qcs->sd->conn = qcc->conn;
+       se_fl_set(qcs->sd, SE_FL_T_MUX | SE_FL_ORPHAN | SE_FL_NOT_FIRST);
+       se_expect_no_data(qcs->sd);
+
+       if (!(global.tune.no_zero_copy_fwd & NO_ZERO_COPY_FWD_QUIC_SND))
+               se_fl_set(qcs->sd, SE_FL_MAY_FASTFWD_CONS);
+
        if (!sc_new_from_endp(qcs->sd, sess, buf)) {
                TRACE_DEVEL("leaving on error", QMUX_EV_STRM_RECV, qcc->conn, qcs);
                return -1;