Skip to content

Commit 4aefeb7

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 47d52cd commit 4aefeb7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

mem-pool.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
#include "git-compat-util.h"
66
#include "mem-pool.h"
7+
#include "trace.h"
78

9+
static struct trace_key trace_mem_pool = TRACE_KEY_INIT(MEMPOOL);
810
#define BLOCK_GROWTH_SIZE (1024 * 1024 - sizeof(struct mp_block))
911

1012
/*
@@ -62,12 +64,20 @@ void mem_pool_init(struct mem_pool *pool, size_t initial_size)
6264

6365
if (initial_size > 0)
6466
mem_pool_alloc_block(pool, initial_size, NULL);
67+
68+
trace_printf_key(&trace_mem_pool,
69+
"mem_pool (%p): init (%"PRIuMAX") initial size\n",
70+
(void *)pool, (uintmax_t)initial_size);
6571
}
6672

6773
void mem_pool_discard(struct mem_pool *pool, int invalidate_memory)
6874
{
6975
struct mp_block *block, *block_to_free;
7076

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

0 commit comments

Comments
 (0)