From 1bcb695a05bb791d927042e99bb54149b5c2bc67 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Fri, 28 Apr 2023 16:24:44 +0200 Subject: [PATCH] MINOR: quic: use real sending rate measurement 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 | 12 ++++++++++++ src/quic_sock.c | 8 -------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/mux_quic.c b/src/mux_quic.c index 4019de5..44a8d27 100644 --- a/src/mux_quic.c +++ b/src/mux_quic.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -19,6 +20,7 @@ #include #include #include +#include #include 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)) { diff --git a/src/quic_sock.c b/src/quic_sock.c index 37b4803..55920d2 100644 --- a/src/quic_sock.c +++ b/src/quic_sock.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -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; } -- 1.7.10.4