]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: window_filter: rely on the time to update the filter samples (QUIC/BBR)
authorFrederic Lecaille <flecaille@haproxy.com>
Thu, 12 Dec 2024 08:59:35 +0000 (09:59 +0100)
committerFrederic Lecaille <flecaille@haproxy.com>
Fri, 13 Dec 2024 13:42:43 +0000 (14:42 +0100)
The windowed filters are used only the BBR implementation for QUIC to filter
the maximum bandwidth samples for its estimation over a virtual time interval
tracked by counting the cyclical progression through ProbeBW cycles. ngtcp2
and quiche use such windowed filters in their BBR implementation. But in a
slightly different way. When updating the 2nd or 3rd filter samples, this
is done based on their values in place of the time they have been sampled.
It seems more logical to rely on the sample timestamps even if this has no
implication because when a sample is updated using another sample because it
has the same value, they have both the same timestamps!

This patch modifies two statements which compare two consecutive filter samples
based on their values (smp[]->v) by statements which compare them based on the
virtual time they have been sampled (smp[]->t). This fully complies which the
code used by the Linux kernel in lib/win_minmax.c.

Alo take the opportunity of this patch to shorten some statements using <smp>
local variable value to update smp[2] sample in place of initializing its two
members with the <smp> member values.

This patch SHOULD be easily backported to 3.1 where BBR was first implemented.

include/haproxy/window_filter.h

index 810dd277e7827e2939b8f19045e01979adb30839..63bc1db52c296887799635e7975e4b22f881f50d 100644 (file)
@@ -76,20 +76,17 @@ static inline uint64_t wf_max_update(struct wf *wf, uint64_t v, uint32_t t)
        if (unlikely(delta_t > wf->len)) {
                wf->smp[0] = wf->smp[1];
                wf->smp[1] = wf->smp[2];
-               wf->smp[2].v = v;
-               wf->smp[2].t = t;
+               wf->smp[2] = smp;
 
                if (unlikely(t - wf->smp[0].t > wf->len)) {
                        wf->smp[0] = wf->smp[1];
                        wf->smp[1] = wf->smp[2];
                }
-       } else if (unlikely(wf->smp[1].v == wf->smp[0].v) && delta_t > wf->len / 4) {
-               wf->smp[2].v = v;
-               wf->smp[2].t = t;
+       } else if (unlikely(wf->smp[1].t == wf->smp[0].t) && delta_t > wf->len / 4) {
+               wf->smp[2] = smp;
                wf->smp[1] = wf->smp[2];
-       } else if (unlikely(wf->smp[2].v == wf->smp[1].v) && delta_t > wf->len / 2) {
-               wf->smp[2].v = v;
-               wf->smp[2].t = t;
+       } else if (unlikely(wf->smp[2].t == wf->smp[1].t) && delta_t > wf->len / 2) {
+               wf->smp[2] = smp;
        }
 
        return wf->smp[0].v;