]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic/pacing: implement quic_pacer engine
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 18 Nov 2024 13:57:39 +0000 (14:57 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 19 Nov 2024 15:16:48 +0000 (16:16 +0100)
Extend quic_pacer engine to support pacing emission. Several functions
are defined.
* quic_pacing_sent_done() to notify engine about an emission of one or
  several datagrams
* quic_pacing_expired() to check if emission should be delayed or can be
  conducted immediately

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

index b4e72e78dcbe84fd2fffc404ec89cd1c357d2489..d06b221169e41b4861d00c4a27cb41c6ebdf6f02 100644 (file)
@@ -123,6 +123,9 @@ struct quic_cc_algo {
        void (*state_trace)(struct buffer *buf, const struct quic_cc *cc);
        void (*state_cli)(struct buffer *buf, const struct quic_cc_path *path);
        void (*hystart_start_round)(struct quic_cc *cc, uint64_t pn);
+
+       /* Defined only if pacing is used. */
+       uint (*pacing_rate)(const struct quic_cc *cc);
 };
 
 #endif /* USE_QUIC */
index 269a931016e848a755fb2fcf24b51e8db324a49b..b9ae6ccd398eab053ed9ee68c121b945a55aac1e 100644 (file)
@@ -37,6 +37,9 @@ void quic_cc_init(struct quic_cc *cc, struct quic_cc_algo *algo, struct quic_con
 void quic_cc_event(struct quic_cc *cc, struct quic_cc_event *ev);
 void quic_cc_state_trace(struct buffer *buf, const struct quic_cc *cc);
 
+/* Pacing callbacks */
+uint quic_cc_default_pacing_rate(const struct quic_cc *cc);
+
 static inline const char *quic_cc_state_str(enum quic_cc_algo_state_type state)
 {
        switch (state) {
@@ -107,6 +110,5 @@ static inline size_t quic_cc_path_prep_data(struct quic_cc_path *path)
        return path->cwnd - path->prep_in_flight;
 }
 
-
 #endif /* USE_QUIC */
 #endif /* _PROTO_QUIC_CC_H */
index 2315c2f65e99f57224d2b3f9400fd7390d60d9fb..01e3776fd4f99c0f0030b24be23c9657ab1aaea4 100644 (file)
@@ -6,6 +6,7 @@
 
 struct quic_pacer {
        const struct quic_cc *cc; /* Congestion controler algo used for this connection */
+       ullong next; /* Nanosecond timestamp at which the next emission should be conducted */
 };
 
 #endif /* _HAPROXY_QUIC_PACING_T_H */
index 5ef11a53193d936bde661c823ce9091c56f027a8..f6e9228f018ccc9f15c9200bdd5210de5966d198 100644 (file)
@@ -10,6 +10,11 @@ static inline void quic_pacing_init(struct quic_pacer *pacer,
                                     const struct quic_cc *cc)
 {
        pacer->cc = cc;
+       pacer->next = 0;
 }
 
+int quic_pacing_expired(const struct quic_pacer *pacer);
+
+void quic_pacing_sent_done(struct quic_pacer *pacer);
+
 #endif /* _HAPROXY_QUIC_PACING_H */
index 8fd99d3c1989b6994fe7fc278bdb552a169c319b..c09b9d890eaf76cc294baf9812b714ac575fee03 100644 (file)
@@ -47,3 +47,10 @@ void quic_cc_state_trace(struct buffer *buf, const struct quic_cc *cc)
 {
        cc->algo->state_trace(buf, cc);
 }
+
+/* Return rate in nanoseconds between each datagram emission for a smooth pacing. */
+uint quic_cc_default_pacing_rate(const struct quic_cc *cc)
+{
+       struct quic_cc_path *path = container_of(cc, struct quic_cc_path, cc);
+       return path->loss.srtt * 1000000 / (path->cwnd / path->mtu + 1);
+}
index faee5e81c21b7eca59f020348058c6762acbe05e..9afe957092b162d9865a5a48a2b71c731154c1a7 100644 (file)
@@ -1 +1,15 @@
 #include <haproxy/quic_pacing.h>
+
+#include <haproxy/quic_tx.h>
+
+/* Returns true if <pacer> timer is expired and emission can be retried. */
+int quic_pacing_expired(const struct quic_pacer *pacer)
+{
+       return !pacer->next || pacer->next <= now_mono_time();
+}
+
+/* Notify <pacer> about an emission of one datagram. */
+void quic_pacing_sent_done(struct quic_pacer *pacer)
+{
+       pacer->next = now_mono_time() + pacer->cc->algo->pacing_rate(pacer->cc);
+}