Repository: nginx/nginx
File: src/event/quic/ngx_event_quic_ack.c (C)

Code before:
}


static void
ngx_quic_drop_ack_ranges(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx,
    uint64_t pn)
{
    uint64_t               base;
    ngx_uint_t             i, smallest, largest;
    ngx_quic_ack_range_t  *r;

    ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0,
                   "quic ngx_quic_drop_ack_ranges pn:%uL largest:%uL"
                   " fr:%uL nranges:%ui", pn, ctx->largest_range,
                   ctx->first_range, ctx->nranges);

    base = ctx->largest_range;

    if (base == NGX_QUIC_UNSET_PN) {
        return;
    }

    if (ctx->pending_ack != NGX_QUIC_UNSET_PN && pn >= ctx->pending_ack) {
        ctx->pending_ack = NGX_QUIC_UNSET_PN;
    }

    largest = base;
    smallest = largest - ctx->first_range;

    if (pn >= largest) {
        ctx->largest_range = NGX_QUIC_UNSET_PN;
        ctx->first_range = 0;
        ctx->nranges = 0;
        return;
    }

    if (pn >= smallest) {
        ctx->first_range = largest - pn - 1;
        ctx->nranges = 0;
        return;
    }

    for (i = 0; i < ctx->nranges; i++) {
        r = &ctx->ranges[i];

        largest = smallest - r->gap - 2;
        smallest = largest - r->range;

        if (pn >= largest) {
            ctx->nranges = i;
            return;

Review comment (performance):
This would regress to pre-b874b822e state.

Anyway, I see little purpose in logging the cg->ssthresh value at all.
It is logged in slow start phase only, with a prior known value -1 (or huge numeric),
until the first packet loss detection.  Then the `(cg->window < cg->ssthresh)` condition is never true.

Code after:
    }

    timer = f->send_time - cg->recovery_start;

    if ((ngx_msec_int_t) timer <= 0) {
        ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
                       "quic congestion ack rec t:%M win:%uz if:%uz",
                       now, cg->window, cg->in_flight);

        goto done;
    }

    if (cg->idle) {
        ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
                       "quic congestion ack idle t:%M win:%uz if:%uz",
                       now, cg->window, cg->in_flight);

        goto done;
    }

    if (cg->window < cg->ssthresh) {
        cg->window += f->plen;

        ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0,
                       "quic congestion ack ss t:%M win:%uz ss:%z if:%uz",
                       now, cg->window, cg->ssthresh, cg->in_flight);

    } else {

        /* RFC 9438, 4.2. Window Increase Function */

        w_cubic = ngx_quic_congestion_cubic(c);

        if (cg->window < cg->w_prior) {
            cg->w_est += (uint64_t) cg->mtu * f->plen
                         * 3 * (10 - NGX_QUIC_CUBIC_BETA)
                         / (10 + NGX_QUIC_CUBIC_BETA) / cg->window;

        } else {
            cg->w_est += (uint64_t) cg->mtu * f->plen / cg->window;
        }

        if (w_cubic < cg->w_est) {
            cg->window = cg->w_est;

            ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0,
                       "quic congestion ack reno t:%M win:%uz c:%uz if:%uz",
                       now, cg->window, w_cubic, cg->in_flight);

        } else if (w_cubic > cg->window) {