]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: quic: Wrong K CUBIC calculation.
authorFrederic Lecaille <flecaille@haproxy.com>
Mon, 12 Feb 2024 10:07:54 +0000 (11:07 +0100)
committerFrederic Lecaille <flecaille@haproxy.com>
Mon, 12 Feb 2024 12:44:42 +0000 (13:44 +0100)
The formula for K CUBIC calculation is as follows:

K = cubic_root(W_max * (1 - beta_quic) / C).

Note that this does not match the comment. But the aim of this patch is to not
hide a bug inside another patch to update this K CUBIC calculation.

The unit of C is bytes/s^3 (or segments/s^3). And we want to store K as
milliseconds. So, the conversion inside the cubic_root() to convert seconds in
milliseconds is wrong. The unit used here is bytes/(ms/1000)^3 or
bytes*1000^3/ms^3. That said, it is preferable to compute K as seconds, then
convert to milliseconds as done by this patch.

Must be backported as far as 2.6.

src/quic_cc_cubic.c

index a0f85466f84b11d6292d5a58825e0cf40fc0d3f7..7c478c63400e572a63f2e2a696a9e4a3d9365872 100644 (file)
@@ -242,7 +242,9 @@ static inline void quic_cubic_update(struct quic_cc *cc, uint32_t acked)
                         * Note that K is stored in milliseconds.
                         */
                        c->K = cubic_root((c->last_w_max - path->cwnd) *
-                                         (CUBIC_ONE_SCALED - CUBIC_BETA_SCALED) * 1000 / (CUBIC_C_SCALED * path->mtu));
+                                         (CUBIC_ONE_SCALED - CUBIC_BETA_SCALED) / (CUBIC_C_SCALED * path->mtu));
+                       /* Convert to miliseconds. */
+                       c->K *= 1000;
                        c->W_target = c->last_w_max;
                }