]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic: add counter for interrupted reception
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 27 Oct 2022 15:56:27 +0000 (17:56 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 27 Oct 2022 16:35:42 +0000 (18:35 +0200)
Add a new counter "quic_rxbuf_full". It is incremented each time
quic_sock_fd_iocb() is interrupted on full buffer.

This should help to debug github issue #1903. It is suspected that
QUIC receiver buffers are full which in turn cause quic_sock_fd_iocb()
to be called repeatedly resulting in a high CPU consumption.

include/haproxy/quic_stats-t.h
src/quic_sock.c
src/quic_stats.c

index 08e9caadb64894348c2590c99bdc819f82d58423..95d0af9e6170fa2ea1417b2ca910409dbeb06317 100644 (file)
@@ -9,6 +9,7 @@
 extern struct stats_module quic_stats_module;
 
 enum {
+       QUIC_ST_RXBUF_FULL,
        QUIC_ST_DROPPED_PACKET,
        QUIC_ST_DROPPED_PACKET_BUFOVERRUN,
        QUIC_ST_DROPPED_PARSING,
@@ -52,6 +53,7 @@ enum {
 };
 
 struct quic_counters {
+       long long rxbuf_full;        /* receive operation cancelled due to full buffer */
        long long dropped_pkt;       /* total number of dropped packets */
        long long dropped_pkt_bufoverrun;/* total number of dropped packets because of buffer overrun */
        long long dropped_parsing;   /* total number of dropped packets upon parsing errors */
index 0f8185a4a4d15f33e0d80733d7f853f61b31ed3a..03cb9637724fe19e85fdffba3ad2b4b0c1069e5e 100644 (file)
@@ -389,13 +389,17 @@ void quic_sock_fd_iocb(int fd)
        max_sz = params->max_udp_payload_size;
        cspace = b_contig_space(buf);
        if (cspace < max_sz) {
+               struct proxy *px = l->bind_conf->frontend;
+               struct quic_counters *prx_counters = EXTRA_COUNTERS_GET(px->extra_counters_fe, &quic_stats_module);
                struct quic_dgram *dgram;
 
                /* Do no mark <buf> as full, and do not try to consume it
                 * if the contiguous remaining space is not at the end
                 */
-               if (b_tail(buf) + cspace < b_wrap(buf))
+               if (b_tail(buf) + cspace < b_wrap(buf)) {
+                       HA_ATOMIC_INC(&prx_counters->rxbuf_full);
                        goto out;
+               }
 
                /* Allocate a fake datagram, without data to locate
                 * the end of the RX buffer (required during purging).
@@ -414,8 +418,10 @@ void quic_sock_fd_iocb(int fd)
 
                /* Consume the remaining space */
                b_add(buf, cspace);
-               if (b_contig_space(buf) < max_sz)
+               if (b_contig_space(buf) < max_sz) {
+                       HA_ATOMIC_INC(&prx_counters->rxbuf_full);
                        goto out;
+               }
        }
 
        dgram_buf = (unsigned char *)b_tail(buf);
index 73b03e42ab4e82b8dfdd7ef7b29def8efda4009f..6523951580d71e9275947c2ca7c95af027e90eba 100644 (file)
@@ -3,6 +3,8 @@
 #include <haproxy/stats.h>
 
 static struct name_desc quic_stats[] = {
+       [QUIC_ST_RXBUF_FULL]          = { .name = "quic_rxbuf_full",
+                                         .desc = "Total number of cancelled reception due to full receiver buffer" },
        [QUIC_ST_DROPPED_PACKET]      = { .name = "quic_dropped_pkt",
                                          .desc = "Total number of dropped packets" },
        [QUIC_ST_DROPPED_PACKET_BUFOVERRUN] = { .name = "quic_dropped_pkt_bufoverrun",
@@ -87,6 +89,7 @@ static void quic_fill_stats(void *data, struct field *stats)
 {
        struct quic_counters *counters = data;
 
+       stats[QUIC_ST_RXBUF_FULL]        = mkf_u64(FN_COUNTER, counters->rxbuf_full);
        stats[QUIC_ST_DROPPED_PACKET]    = mkf_u64(FN_COUNTER, counters->dropped_pkt);
        stats[QUIC_ST_DROPPED_PACKET_BUFOVERRUN] = mkf_u64(FN_COUNTER, counters->dropped_pkt_bufoverrun);
        stats[QUIC_ST_DROPPED_PARSING]   = mkf_u64(FN_COUNTER, counters->dropped_parsing);