From: Amaury Denoyelle Date: Wed, 20 May 2026 07:01:04 +0000 (+0200) Subject: OPTIM: h2: do not update committed streams if elasticity disabled X-Git-Tag: v3.4-dev13~22 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=33c8270903aefb6925111f4eb5e3d537a0e11439;p=thirdparty%2Fhaproxy.git OPTIM: h2: do not update committed streams if elasticity disabled When streams-elasticity is enabled in the configuration, H2 mux is responsible to update the global committed_extra_streams value. Adjust these operations to ensure they are skipped if streams-elasticity is disabled, which is the current default. This prevents unnecessary atomic operations in this case. No need to backport unless streams-elasticity feature is picked in older releases. --- diff --git a/src/mux_h2.c b/src/mux_h2.c index 1c29cf5cc..37162fc3c 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -1456,7 +1456,7 @@ static int h2_init(struct connection *conn, struct proxy *prx, struct session *s if (max_strm && h2c->streams_hard_limit > max_strm) h2c->streams_limit = h2c->streams_hard_limit = max_strm; - if (h2c->streams_hard_limit > 1) + if (global.tune.streams_elasticity && h2c->streams_hard_limit > 1) _HA_ATOMIC_ADD(&tg_ctx->committed_extra_streams, h2c->streams_hard_limit - 1); } @@ -1530,7 +1530,7 @@ static int h2_init(struct connection *conn, struct proxy *prx, struct session *s /* Unnecessary code for now as fail_stream only occurs with BE conns. * Still better though to keep it to prevent future mistakes. */ - if (!(h2c->flags & H2_CF_IS_BACK) && h2c->streams_hard_limit > 1) + if (!(h2c->flags & H2_CF_IS_BACK) && global.tune.streams_elasticity && h2c->streams_hard_limit > 1) _HA_ATOMIC_SUB(&tg_ctx->committed_extra_streams, h2c->streams_hard_limit - 1); hpack_dht_free(h2c->ddht); fail: @@ -1610,7 +1610,7 @@ static void h2_release(struct h2c *h2c) if (!conn || !conn_is_reverse(conn)) HA_ATOMIC_DEC(&h2c->px_counters->open_conns); - if (!(h2c->flags & H2_CF_IS_BACK) && h2c->streams_hard_limit > 1) + if (!(h2c->flags & H2_CF_IS_BACK) && global.tune.streams_elasticity && h2c->streams_hard_limit > 1) _HA_ATOMIC_SUB(&tg_ctx->committed_extra_streams, h2c->streams_hard_limit - 1); pool_free(pool_head_h2_rx_bufs, h2c->shared_rx_bufs); @@ -4200,7 +4200,7 @@ static int h2_conn_reverse(struct h2c *h2c) /* the connection was accounted as frontend streams before * reversal, we must undo that accounting now. */ - if (h2c->streams_hard_limit > 1) + if (h2c->streams_hard_limit > 1 && global.tune.streams_elasticity) _HA_ATOMIC_SUB(&tg_ctx->committed_extra_streams, h2c->streams_hard_limit - 1); h2c->flags |= H2_CF_IS_BACK; @@ -4222,7 +4222,7 @@ static int h2_conn_reverse(struct h2c *h2c) struct proxy *prx = l->bind_conf->frontend; /* backend connections becoming frontend need accounting. */ - if (h2c->streams_hard_limit > 1) + if (h2c->streams_hard_limit > 1 && global.tune.streams_elasticity) _HA_ATOMIC_ADD(&tg_ctx->committed_extra_streams, h2c->streams_hard_limit - 1); h2c->flags &= ~H2_CF_IS_BACK;