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.
This commit is contained in:
Amaury Denoyelle 2025-11-20 18:15:21 +01:00
parent 4fb8908605
commit e6064c5616

View 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_reset(&qcs->timer.fctl);
tot_time_start(&qcs->timer.base); 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. */ /* Allocate transport layer stream descriptor. Only needed for TX. */
if (!quic_stream_is_uni(id) || !quic_stream_is_remote(qcc, id)) { if (!quic_stream_is_uni(id) || !quic_stream_is_remote(qcc, id)) {
struct quic_conn *qc = qcc->conn->handle.qc; 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 */ /* TODO duplicated from mux_h2 */
sess->t_idle = ns_to_ms(now_ns - sess->accept_ts) - sess->t_handshake; 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)) { if (!sc_new_from_endp(qcs->sd, sess, buf)) {
TRACE_DEVEL("leaving on error", QMUX_EV_STRM_RECV, qcc->conn, qcs); TRACE_DEVEL("leaving on error", QMUX_EV_STRM_RECV, qcc->conn, qcs);
return -1; return -1;