]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: adapt credit based pacing to BBR
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 23 Jan 2025 14:24:09 +0000 (15:24 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 23 Jan 2025 16:41:07 +0000 (17:41 +0100)
Credit based pacing has been further refined to be able to calculate
dynamically burst size based on congestion parameter. However, BBR
algorithm already provides pacing rate and burst size (labelled as
send_quantum) for 1ms of emission.

Adapt quic_pacing_reload() to use BBR values to compute pacing credit.
This is done via pacing_burst callback which is now only defined for
BBR. For other algorithms, determine the burst size over 1ms with the
congestion window size and RTT.

This should be backported up to 3.1.

src/quic_pacing.c

index 000c957b28941860db2293845fffe85dbb09a986..856c5eebe5d425c4cd82400219de256e7b6ddb36 100644 (file)
@@ -22,11 +22,15 @@ int quic_pacing_reload(struct quic_pacer *pacer)
        const uint64_t task_now_ns = task_mono_time();
        const uint64_t inter = pacer->cc->algo->pacing_inter(pacer->cc);
        uint64_t inc, wakeup_delay;
-       uint credit_max;
+       uint credit_max, pkt_ms;
+
+       /* Calculate the amount of packets which could be emitted in 1ms. */
+       pkt_ms = pacer->cc->algo->pacing_burst ?
+         pacer->cc->algo->pacing_burst(pacer->cc) : (1000000 + inter - 1) / inter;
 
        if (task_now_ns > pacer->cur) {
                /* Calculate number of packets which could have been emitted since last emission sequence. Result is rounded up. */
-               inc = (task_now_ns - pacer->cur + inter - 1) / inter;
+               inc = (pkt_ms * (task_now_ns - pacer->cur) + 999999) / 1000000;
 
                /* Credit must not exceed a maximal value to guarantee a
                 * smooth emission. This max value represents the number of
@@ -40,7 +44,7 @@ int quic_pacing_reload(struct quic_pacer *pacer)
                /* Convert it to nanoseconds. Use 1.5 factor tolerance to try to cover the imponderable extra system delay until the next wakeup. */
                wakeup_delay *= 1500;
                /* Determine max credit from wakeup_delay and packet rate emission. */
-               credit_max = wakeup_delay / inter;
+               credit_max = (wakeup_delay * pkt_ms + 999999) / 1000000;
                /* Ensure max credit will never be smaller than 2. */
                credit_max = MAX(credit_max, 2);
                /* Apply max credit on the new value. */