Skip to content

Commit 0013860

Browse files
benpeartdscho
authored andcommitted
mem_pool: add GIT_TRACE_MEMPOOL support
Add tracing around initializing and discarding mempools. In discard report on the amount of memory unused in the current block to help tune setting the initial_size. Signed-off-by: Ben Peart <[email protected]>
1 parent 04c0ae9 commit 0013860

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

mem-pool.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "cache.h"
66
#include "mem-pool.h"
77

8+
static struct trace_key trace_mem_pool = TRACE_KEY_INIT(MEMPOOL);
89
#define BLOCK_GROWTH_SIZE 1024*1024 - sizeof(struct mp_block);
910

1011
/*
@@ -42,12 +43,17 @@ void mem_pool_init(struct mem_pool *pool, size_t initial_size)
4243

4344
if (initial_size > 0)
4445
mem_pool_alloc_block(pool, initial_size, NULL);
46+
47+
trace_printf_key(&trace_mem_pool, "mem_pool (%p): init (%"PRIuMAX") initial size\n",
48+
pool, (uintmax_t)initial_size);
4549
}
4650

4751
void mem_pool_discard(struct mem_pool *pool, int invalidate_memory)
4852
{
4953
struct mp_block *block, *block_to_free;
5054

55+
trace_printf_key(&trace_mem_pool, "mem_pool (%p): discard (%"PRIuMAX") unused\n",
56+
pool, (uintmax_t)(pool->mp_block->end - pool->mp_block->next_free));
5157
block = pool->mp_block;
5258
while (block)
5359
{

0 commit comments

Comments
 (0)