]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: More precise window update calculation
authorFrédéric Lécaille <flecaille@haproxy.com>
Thu, 3 Mar 2022 06:50:45 +0000 (07:50 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 4 Mar 2022 16:47:32 +0000 (17:47 +0100)
When in congestion avoidance state and when acknowledging an <acked> number bytes
we must increase the congestion window by at most one datagram (<path->mtu>)
by congestion window. So thanks to this patch we apply a ratio to the current
number of acked bytes : <acked> * <path->mtu> / <cwnd>.
So, when <cwnd> bytes are acked we precisely increment <cwnd> by <path->mtu>.
Furthermore we take into an account the number of remaining acknowledged bytes
each time we increment the window by <acked> storing their values in the algorithm
struct state (->remain_acked) so that it might be take into an account at the
next ACK event.

include/haproxy/quic_cc-t.h
src/quic_cc_newreno.c

index 78af6a587c569363999d61911d1378da9151ebd3..95d9922f09db0921c7e14db7a63f73c5955f8fb7 100644 (file)
@@ -76,6 +76,7 @@ union quic_cc_algo_state {
                uint64_t cwnd;
                uint64_t ssthresh;
                uint64_t recovery_start_time;
+               uint64_t remain_acked;
        } nr;
 };
 
index e15b302b2b55cf17ed5981537605a96ea3ff11ca..39529101534cf83bae29ea8084e421950af16acd 100644 (file)
@@ -35,6 +35,7 @@ static int quic_cc_nr_init(struct quic_cc *cc)
        cc->algo_state.nr.cwnd = path->cwnd;
        cc->algo_state.nr.ssthresh = QUIC_CC_INFINITE_SSTHESH;
        cc->algo_state.nr.recovery_start_time = 0;
+       cc->algo_state.nr.remain_acked = 0;
 
        return 1;
 }
@@ -95,17 +96,20 @@ static void quic_cc_nr_ca_cb(struct quic_cc *cc, struct quic_cc_event *ev)
        path = container_of(cc, struct quic_path, cc);
        switch (ev->type) {
        case QUIC_CC_EVT_ACK:
+       {
+               uint64_t acked;
                /* Do not increase the congestion window in recovery period. */
                if (ev->ack.time_sent <= cc->algo_state.nr.recovery_start_time)
                        goto out;
 
-               /* Increasing the congestion window by 1 maximum packet size by
-                * congestion window.
+               /* Increasing the congestion window by (acked / cwnd)
                 */
-               cc->algo_state.nr.cwnd +=
-                       path->mtu * QUIC_MAX(1ULL, (unsigned long long)ev->ack.acked / cc->algo_state.nr.cwnd);
+               acked = ev->ack.acked * path->mtu + cc->algo_state.nr.remain_acked;
+               cc->algo_state.nr.remain_acked = acked % cc->algo_state.nr.cwnd;
+               cc->algo_state.nr.cwnd += acked / cc->algo_state.nr.cwnd;
                path->cwnd = cc->algo_state.nr.cwnd;
                break;
+       }
 
        case QUIC_CC_EVT_LOSS:
                /* Do not decrease the congestion window when already in recovery period. */