Skip to content

Commit 55f376b

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 5fde953 commit 55f376b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

mem-pool.c

+9
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
/*
@@ -62,12 +63,20 @@ void mem_pool_init(struct mem_pool *pool, size_t initial_size)
6263

6364
if (initial_size > 0)
6465
mem_pool_alloc_block(pool, initial_size, NULL);
66+
67+
trace_printf_key(&trace_mem_pool,
68+
"mem_pool (%p): init (%"PRIuMAX") initial size\n",
69+
(void *)pool, (uintmax_t)initial_size);
6570
}
6671

6772
void mem_pool_discard(struct mem_pool *pool, int invalidate_memory)
6873
{
6974
struct mp_block *block, *block_to_free;
7075

76+
trace_printf_key(&trace_mem_pool,
77+
"mem_pool (%p): discard (%"PRIuMAX") unused\n",
78+
(void *)pool,
79+
(uintmax_t)(pool->mp_block->end - pool->mp_block->next_free));
7180
block = pool->mp_block;
7281
while (block)
7382
{

0 commit comments

Comments
 (0)