]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: use real sending rate measurement
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 28 Apr 2023 14:24:44 +0000 (16:24 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 28 Apr 2023 14:52:26 +0000 (16:52 +0200)
Before this patch, global sending rate was measured on the QUIC lower
layer just after sendto(). This meant that all QUIC frames were
accounted for, including non STREAM frames and also retransmission.

To have a better reflection of the application data transferred, move
the incrementation into the MUX layer. This allows to account only for
STREAM frames payload on their first emission.

This should be backported up to 2.6.

src/mux_quic.c
src/quic_sock.c

index 4019de5b927ec889022f8278a6d3cf402a11aded..44a8d2729c95f90ee239ae8b13b7e624757730d5 100644 (file)
@@ -5,6 +5,7 @@
 #include <haproxy/api.h>
 #include <haproxy/connection.h>
 #include <haproxy/dynbuf.h>
+#include <haproxy/freq_ctr.h>
 #include <haproxy/h3.h>
 #include <haproxy/list.h>
 #include <haproxy/ncbuf.h>
@@ -19,6 +20,7 @@
 #include <haproxy/quic_tp-t.h>
 #include <haproxy/ssl_sock-t.h>
 #include <haproxy/stconn.h>
+#include <haproxy/thread.h>
 #include <haproxy/trace.h>
 
 DECLARE_POOL(pool_head_qcc, "qcc", sizeof(struct qcc));
@@ -1643,6 +1645,16 @@ void qcc_streams_sent_done(struct qcs *qcs, uint64_t data, uint64_t offset)
                    b_full(&qcs->stream->buf->buf)) {
                        qc_stream_buf_release(qcs->stream);
                }
+
+               /* Add measurement for send rate. This is done at the MUX layer
+                * to account only for STREAM frames without retransmission.
+                *
+                * we count the total bytes sent, and the send rate for 32-byte blocks.
+                * The reason for the latter is that freq_ctr are limited to 4GB and
+                * that it's not enough per second.
+                */
+               _HA_ATOMIC_ADD(&th_ctx->out_bytes, ret);
+               update_freq_ctr(&th_ctx->out_32bps, (ret + 16) / 32);
        }
 
        if (qcs->tx.offset == qcs->tx.sent_offset && !b_data(&qcs->tx.buf)) {
index 37b48033b92db2f850d2ee8476e462031ab19b1d..55920d2f5207eba3dd48b0738fa2f7c10c393a63 100644 (file)
@@ -24,7 +24,6 @@
 #include <haproxy/connection.h>
 #include <haproxy/dynbuf.h>
 #include <haproxy/fd.h>
-#include <haproxy/freq_ctr.h>
 #include <haproxy/global-t.h>
 #include <haproxy/list.h>
 #include <haproxy/listener.h>
@@ -663,13 +662,6 @@ int qc_snd_buf(struct quic_conn *qc, const struct buffer *buf, size_t sz,
        if (ret != sz)
                return 0;
 
-       /* we count the total bytes sent, and the send rate for 32-byte blocks.
-        * The reason for the latter is that freq_ctr are limited to 4GB and
-        * that it's not enough per second.
-        */
-       _HA_ATOMIC_ADD(&th_ctx->out_bytes, ret);
-       update_freq_ctr(&th_ctx->out_32bps, (ret + 16) / 32);
-
        return ret;
 }