MINOR: activity: report the number of failed pool/buffer allocations
Haproxy is designed to be able to continue to run even under very low
memory conditions. However this can sometimes have a serious impact on
performance that it hard to diagnose. Let's report counters of failed
pool and buffer allocations per thread in show activity.
diff --git a/src/memory.c b/src/memory.c
index 6555913..6331c84 100644
--- a/src/memory.c
+++ b/src/memory.c
@@ -25,6 +25,8 @@
#include <common/mini-clist.h>
#include <common/standard.h>
+#include <types/activity.h>
+
#include <proto/applet.h>
#include <proto/cli.h>
#include <proto/channel.h>
@@ -160,14 +162,17 @@
while (1) {
if (limit && allocated >= limit) {
_HA_ATOMIC_ADD(&pool->allocated, allocated - allocated_orig);
+ activity[tid].pool_fail++;
return NULL;
}
ptr = malloc(size + POOL_EXTRA);
if (!ptr) {
_HA_ATOMIC_ADD(&pool->failed, 1);
- if (failed)
+ if (failed) {
+ activity[tid].pool_fail++;
return NULL;
+ }
failed++;
pool_gc(pool);
continue;
@@ -317,14 +322,18 @@
avail += pool->used;
while (1) {
- if (pool->limit && pool->allocated >= pool->limit)
+ if (pool->limit && pool->allocated >= pool->limit) {
+ activity[tid].pool_fail++;
return NULL;
+ }
ptr = pool_alloc_area(pool->size + POOL_EXTRA);
if (!ptr) {
pool->failed++;
- if (failed)
+ if (failed) {
+ activity[tid].pool_fail++;
return NULL;
+ }
failed++;
pool_gc(pool);
continue;