mirror of
https://github.com/git-for-windows/git.git
synced 2026-05-01 21:59:56 -05:00
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>
This commit is contained in:
committed by
Johannes Schindelin
parent
6453004b6d
commit
f66b44d5ba
10
mem-pool.c
10
mem-pool.c
@@ -4,7 +4,9 @@
|
|||||||
|
|
||||||
#include "git-compat-util.h"
|
#include "git-compat-util.h"
|
||||||
#include "mem-pool.h"
|
#include "mem-pool.h"
|
||||||
|
#include "trace.h"
|
||||||
|
|
||||||
|
static struct trace_key trace_mem_pool = TRACE_KEY_INIT(MEMPOOL);
|
||||||
#define BLOCK_GROWTH_SIZE (1024 * 1024 - sizeof(struct mp_block))
|
#define BLOCK_GROWTH_SIZE (1024 * 1024 - sizeof(struct mp_block))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -62,12 +64,20 @@ void mem_pool_init(struct mem_pool *pool, size_t initial_size)
|
|||||||
|
|
||||||
if (initial_size > 0)
|
if (initial_size > 0)
|
||||||
mem_pool_alloc_block(pool, initial_size, NULL);
|
mem_pool_alloc_block(pool, initial_size, NULL);
|
||||||
|
|
||||||
|
trace_printf_key(&trace_mem_pool,
|
||||||
|
"mem_pool (%p): init (%"PRIuMAX") initial size\n",
|
||||||
|
(void *)pool, (uintmax_t)initial_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mem_pool_discard(struct mem_pool *pool, int invalidate_memory)
|
void mem_pool_discard(struct mem_pool *pool, int invalidate_memory)
|
||||||
{
|
{
|
||||||
struct mp_block *block, *block_to_free;
|
struct mp_block *block, *block_to_free;
|
||||||
|
|
||||||
|
trace_printf_key(&trace_mem_pool,
|
||||||
|
"mem_pool (%p): discard (%"PRIuMAX") unused\n",
|
||||||
|
(void *)pool,
|
||||||
|
(uintmax_t)(pool->mp_block->end - pool->mp_block->next_free));
|
||||||
block = pool->mp_block;
|
block = pool->mp_block;
|
||||||
while (block)
|
while (block)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user