]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-quic: account Rx data per stream
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 24 Mar 2025 10:27:27 +0000 (11:27 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 13 May 2025 13:41:51 +0000 (15:41 +0200)
Add counters to measure Rx buffers usage per QCS. This reused the newly
defined bdata_ctr type already used for Tx accounting.

Note that for now, <tot> value of bdata_ctr is not used. This is because
it is not easy to account for data accross contiguous buffers.

These values are displayed both on log/traces and "show quic" output.

include/haproxy/mux_quic-t.h
src/mux_quic.c
src/qmux_trace.c

index 1c7c19a32a01e74514eb5a47af6f819d3a8d1f16..6ce9adfe21bad9a60c0012d7ae83782d31460469 100644 (file)
@@ -17,6 +17,7 @@
 #include <haproxy/quic_frame-t.h>
 #include <haproxy/quic_pacing-t.h>
 #include <haproxy/quic_stream-t.h>
+#include <haproxy/quic_utils-t.h>
 #include <haproxy/stconn-t.h>
 #include <haproxy/task-t.h>
 #include <haproxy/time-t.h>
@@ -157,6 +158,7 @@ struct qcs {
                struct buffer app_buf; /* receive buffer used by stconn layer */
                uint64_t msd; /* current max-stream-data limit to enforce */
                uint64_t msd_base; /* max-stream-data previous to latest update */
+               struct bdata_ctr data; /* data utilization counter. Note that <tot> is now used for now as accounting may be difficult with ncbuf. */
        } rx;
        struct {
                struct quic_fctl fc; /* stream flow control applied on sending */
index 6a0b3189780d75e3bde5980d76aff8f28e06033b..b335eaecff2ce5f7c5d8317ecdd1a7a07240182c 100644 (file)
@@ -67,6 +67,7 @@ static void qcs_free_rxbuf(struct qcs *qcs, struct qc_stream_rxbuf *rxbuf)
 
        eb64_delete(&rxbuf->off_node);
        pool_free(pool_head_qc_stream_rxbuf, rxbuf);
+       bdata_ctr_bdec(&qcs->rx.data);
 }
 
 /* Free <qcs> instance. This function is reserved for internal usage : it must
@@ -177,6 +178,7 @@ static struct qcs *qcs_new(struct qcc *qcc, uint64_t id, enum qcs_type type)
                qcs->rx.msd = qcc->lfctl.msd_uni_r;
        }
        qcs->rx.msd_base = 0;
+       bdata_ctr_init(&qcs->rx.data);
 
        qcs->wait_event.tasklet = NULL;
        qcs->wait_event.events = 0;
@@ -1151,6 +1153,7 @@ static int qcs_transfer_rx_data(struct qcs *qcs, struct qc_stream_rxbuf *rxbuf)
                        b_free(&b_next);
                        offer_buffers(NULL, 1);
                        pool_free(pool_head_qc_stream_rxbuf, rxbuf_next);
+                       bdata_ctr_bdec(&qcs->rx.data);
                }
 
                ret = 0;
@@ -1723,6 +1726,7 @@ static struct qc_stream_rxbuf *qcs_get_rxbuf(struct qcs *qcs, uint64_t offset,
                buf->off_node.key = aligned_off;
                buf->off_end = aligned_off + qmux_stream_rx_bufsz();
                eb64_insert(&qcs->rx.bufs, &buf->off_node);
+               bdata_ctr_binc(&qcs->rx.data);
        }
 
        ncbuf = &buf->ncb;
@@ -4121,8 +4125,10 @@ void qcc_show_quic(struct qcc *qcc)
                              qcs, (ullong)qcs->id, qcs->flags,
                              qcs_st_to_str(qcs->st));
 
-               if (!quic_stream_is_uni(qcs->id) || !quic_stream_is_local(qcc, qcs->id))
+               if (!quic_stream_is_uni(qcs->id) || !quic_stream_is_local(qcc, qcs->id)) {
+                       chunk_appendf(&trash, " rxb=%u(%u)", qcs->rx.data.bcnt, qcs->rx.data.bmax);
                        chunk_appendf(&trash, " rxoff=%llu", (ullong)qcs->rx.offset);
+               }
 
                if (!quic_stream_is_uni(qcs->id) || !quic_stream_is_remote(qcc, qcs->id)) {
                        if (qcs->stream)
index 649af8efe8e8a32e170803990578b75cd67aa491..2725647395fb41c2577123631ebfb94ebc1771e5 100644 (file)
@@ -162,7 +162,9 @@ void qmux_dump_qcs_info(struct buffer *msg, const struct qcs *qcs)
        chunk_appendf(msg, " qcs=%p .id=%llu .st=%s .flg=0x%04x", qcs, (ullong)qcs->id,
                      qcs_st_to_str(qcs->st), qcs->flags);
 
-       chunk_appendf(msg, " .rx=%llu/%llu", (ullong)qcs->rx.offset_max, (ullong)qcs->rx.msd);
+       chunk_appendf(msg, " .rx=%llu/%llu rxb=%u(%u)",
+                     (ullong)qcs->rx.offset_max, (ullong)qcs->rx.msd,
+                     qcs->rx.data.bcnt, qcs->rx.data.bmax);
        chunk_appendf(msg, " .tx=%llu %llu/%llu", (ullong)qcs->tx.fc.off_soft,
                                                  (ullong)qcs->tx.fc.off_real,
                                                  (ullong)qcs->tx.fc.limit);