MINOR: quic: add counter for interrupted reception
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.
diff --git a/include/haproxy/quic_stats-t.h b/include/haproxy/quic_stats-t.h
index 08e9caa..95d0af9 100644
--- a/include/haproxy/quic_stats-t.h
+++ b/include/haproxy/quic_stats-t.h
@@ -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 @@
};
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 */
diff --git a/src/quic_sock.c b/src/quic_sock.c
index 0f8185a..03cb963 100644
--- a/src/quic_sock.c
+++ b/src/quic_sock.c
@@ -389,13 +389,17 @@
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 @@
/* 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);
diff --git a/src/quic_stats.c b/src/quic_stats.c
index 73b03e4..6523951 100644
--- a/src/quic_stats.c
+++ b/src/quic_stats.c
@@ -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 @@
{
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);