Skip to content

Commit a72ea66

Browse files
committed
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 <benpeart@microsoft.com>
1 parent b517370 commit a72ea66

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

mem-pool.c

+5
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
/*
@@ -48,12 +49,16 @@ void mem_pool_init(struct mem_pool **mem_pool, size_t initial_size)
4849
mem_pool_alloc_block(pool, initial_size, NULL);
4950

5051
*mem_pool = pool;
52+
trace_printf_key(&trace_mem_pool, "mem_pool (%p): init (%"PRIuMAX") initial size\n",
53+
pool, (uintmax_t)initial_size);
5154
}
5255

5356
void mem_pool_discard(struct mem_pool *mem_pool, int invalidate_memory)
5457
{
5558
struct mp_block *block, *block_to_free;
5659

60+
trace_printf_key(&trace_mem_pool, "mem_pool (%p): discard (%"PRIuMAX") unused\n",
61+
mem_pool, (uintmax_t)(mem_pool->mp_block->end - mem_pool->mp_block->next_free));
5762
block = mem_pool->mp_block;
5863
while (block)
5964
{

0 commit comments

Comments
 (0)