From e6064c561684d9b079e3b5725d38dc3b5c1b5cd5 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Thu, 20 Nov 2025 18:15:21 +0100 Subject: [PATCH] OPTIM: mux-quic: delay FE sedesc alloc to stream creation 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 | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/mux_quic.c b/src/mux_quic.c index 947c10609..2d6fb25b8 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -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;