Implement metadata statistics.

There are three categories of metadata:

- Base allocations are used for bootstrap-sensitive internal allocator
  data structures.
- Arena chunk headers comprise pages which track the states of the
  non-metadata pages.
- Internal allocations differ from application-originated allocations
  in that they are for internal use, and that they are omitted from heap
  profiles.

The metadata statistics comprise the metadata categories as follows:

- stats.metadata: All metadata -- base + arena chunk headers + internal
  allocations.
- stats.arenas.<i>.metadata.mapped: Arena chunk headers.
- stats.arenas.<i>.metadata.allocated: Internal allocations.  This is
  reported separately from the other metadata statistics because it
  overlaps with the allocated and active statistics, whereas the other
  metadata statistics do not.

Base allocations are not reported separately, though their magnitude can
be computed by subtracting the arena-specific metadata.

This resolves #163.
This commit is contained in:
Jason Evans 2014-11-27 17:22:36 -02:00
parent ec98a44662
commit 4581b97809
18 changed files with 393 additions and 204 deletions

View file

@ -16,6 +16,8 @@ static void *base_next_addr;
static void *base_past_addr; /* Addr immediately past base_pages. */
static extent_node_t *base_nodes;
static size_t base_allocated;
/******************************************************************************/
static bool
@ -54,6 +56,8 @@ base_alloc(size_t size)
/* Allocate. */
ret = base_next_addr;
base_next_addr = (void *)((uintptr_t)base_next_addr + csize);
if (config_stats)
base_allocated += csize;
malloc_mutex_unlock(&base_mtx);
JEMALLOC_VALGRIND_MAKE_MEM_UNDEFINED(ret, csize);
@ -102,6 +106,17 @@ base_node_dalloc(extent_node_t *node)
malloc_mutex_unlock(&base_mtx);
}
size_t
base_allocated_get(void)
{
size_t ret;
malloc_mutex_lock(&base_mtx);
ret = base_allocated;
malloc_mutex_unlock(&base_mtx);
return (ret);
}
bool
base_boot(void)
{