mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-22 22:31:28 +02:00
MINOR: pools: report the amount used by thread caches in "show pools"
The "show pools" command provides some "allocated" and "used" estimates on the pools objects, but this applies to the shared pool and the "used" includes what is currently assigned to thread-local caches. It's possible to know how much each thread uses, so let's dump the total size allocated by thread caches as an estimate. It's only done when pools are enabled, which explains why the patch adds quite a lot of ifdefs.
This commit is contained in:
parent
1a9b8a6122
commit
1b4a714266
31
src/pool.c
31
src/pool.c
@ -519,13 +519,30 @@ void dump_pools_to_trash()
|
|||||||
struct pool_head *entry;
|
struct pool_head *entry;
|
||||||
unsigned long allocated, used;
|
unsigned long allocated, used;
|
||||||
int nbpools;
|
int nbpools;
|
||||||
|
#ifdef CONFIG_HAP_POOLS
|
||||||
|
unsigned long cached_bytes = 0;
|
||||||
|
uint cached = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
allocated = used = nbpools = 0;
|
allocated = used = nbpools = 0;
|
||||||
chunk_printf(&trash, "Dumping pools usage. Use SIGQUIT to flush them.\n");
|
chunk_printf(&trash, "Dumping pools usage. Use SIGQUIT to flush them.\n");
|
||||||
list_for_each_entry(entry, &pools, list) {
|
list_for_each_entry(entry, &pools, list) {
|
||||||
chunk_appendf(&trash, " - Pool %s (%u bytes) : %u allocated (%u bytes), %u used, needed_avg %u, %u failures, %u users, @%p%s\n",
|
#ifdef CONFIG_HAP_POOLS
|
||||||
|
int i;
|
||||||
|
for (cached = i = 0; i < global.nbthread; i++)
|
||||||
|
cached += entry->cache[i].count;
|
||||||
|
cached_bytes += cached * entry->size;
|
||||||
|
#endif
|
||||||
|
chunk_appendf(&trash, " - Pool %s (%u bytes) : %u allocated (%u bytes), %u used"
|
||||||
|
#ifdef CONFIG_HAP_POOLS
|
||||||
|
" (~%u by thread caches)"
|
||||||
|
#endif
|
||||||
|
", needed_avg %u, %u failures, %u users, @%p%s\n",
|
||||||
entry->name, entry->size, entry->allocated,
|
entry->name, entry->size, entry->allocated,
|
||||||
entry->size * entry->allocated, entry->used,
|
entry->size * entry->allocated, entry->used,
|
||||||
|
#ifdef CONFIG_HAP_POOLS
|
||||||
|
cached,
|
||||||
|
#endif
|
||||||
swrate_avg(entry->needed_avg, POOL_AVG_SAMPLES), entry->failed,
|
swrate_avg(entry->needed_avg, POOL_AVG_SAMPLES), entry->failed,
|
||||||
entry->users, entry,
|
entry->users, entry,
|
||||||
(entry->flags & MEM_F_SHARED) ? " [SHARED]" : "");
|
(entry->flags & MEM_F_SHARED) ? " [SHARED]" : "");
|
||||||
@ -534,8 +551,16 @@ void dump_pools_to_trash()
|
|||||||
used += entry->used * entry->size;
|
used += entry->used * entry->size;
|
||||||
nbpools++;
|
nbpools++;
|
||||||
}
|
}
|
||||||
chunk_appendf(&trash, "Total: %d pools, %lu bytes allocated, %lu used.\n",
|
chunk_appendf(&trash, "Total: %d pools, %lu bytes allocated, %lu used"
|
||||||
nbpools, allocated, used);
|
#ifdef CONFIG_HAP_POOLS
|
||||||
|
" (~%lu by thread caches)"
|
||||||
|
#endif
|
||||||
|
".\n",
|
||||||
|
nbpools, allocated, used
|
||||||
|
#ifdef CONFIG_HAP_POOLS
|
||||||
|
, cached_bytes
|
||||||
|
#endif
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Dump statistics on pools usage. */
|
/* Dump statistics on pools usage. */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user