Statistics fixes and cleanup.

Fix a type mismatch for "arenas.nlruns" mallctl access.  This bug caused
a crash during statistics printing on 64-bit systems.

Fix the "stats.active" mallctl to include active memory in huge objects.

Report active bytes for the whole application, as well as per arena.

Remove several unused variables.
This commit is contained in:
Jason Evans 2010-01-29 11:24:19 -08:00
parent 4fb7f51337
commit c66aaf1476
3 changed files with 17 additions and 17 deletions

View File

@ -944,7 +944,7 @@ Maximum size supported by this large size class.
@roff_stats@.It Sy "stats.active (size_t) r-" @roff_stats@.It Sy "stats.active (size_t) r-"
@roff_stats@.Bd -ragged -offset indent -compact @roff_stats@.Bd -ragged -offset indent -compact
@roff_stats@Total number of bytes in active pages allocated by the application. @roff_stats@Total number of bytes in active pages allocated by the application.
@roff_stats@This is a multiple of the page size, and is larger than @roff_stats@This is a multiple of the page size, and greater than or equal to
@roff_stats@.Dq stats.allocated . @roff_stats@.Dq stats.allocated .
@roff_stats@.Ed @roff_stats@.Ed
.\"----------------------------------------------------------------------------- .\"-----------------------------------------------------------------------------

View File

@ -529,7 +529,8 @@ ctl_refresh(void)
+ ctl_stats.arenas[narenas].astats.allocated_medium + ctl_stats.arenas[narenas].astats.allocated_medium
+ ctl_stats.arenas[narenas].astats.allocated_large + ctl_stats.arenas[narenas].astats.allocated_large
+ ctl_stats.huge.allocated; + ctl_stats.huge.allocated;
ctl_stats.active = (ctl_stats.arenas[narenas].pactive << PAGE_SHIFT); ctl_stats.active = (ctl_stats.arenas[narenas].pactive << PAGE_SHIFT)
+ ctl_stats.huge.allocated;
ctl_stats.mapped = (ctl_stats.chunks.current << opt_lg_chunk); ctl_stats.mapped = (ctl_stats.chunks.current << opt_lg_chunk);
# ifdef JEMALLOC_SWAP # ifdef JEMALLOC_SWAP

View File

@ -268,7 +268,7 @@ stats_arena_lruns_print(void (*write4)(void *, const char *, const char *,
malloc_cprintf(write4, w4opaque, malloc_cprintf(write4, w4opaque,
"large: size pages nrequests maxruns curruns\n"); "large: size pages nrequests maxruns curruns\n");
CTL_GET("arenas.nlruns", &nlruns, unsigned); CTL_GET("arenas.nlruns", &nlruns, size_t);
for (j = 0, gap_start = -1; j < nlruns; j++) { for (j = 0, gap_start = -1; j < nlruns; j++) {
uint64_t nrequests; uint64_t nrequests;
size_t run_size, highruns, curruns; size_t run_size, highruns, curruns;
@ -303,7 +303,7 @@ static void
stats_arena_print(void (*write4)(void *, const char *, const char *, stats_arena_print(void (*write4)(void *, const char *, const char *,
const char *, const char *), void *w4opaque, unsigned i) const char *, const char *), void *w4opaque, unsigned i)
{ {
size_t pactive, pdirty, mapped; size_t pagesize, pactive, pdirty, mapped;
uint64_t npurge, nmadvise, purged; uint64_t npurge, nmadvise, purged;
size_t small_allocated; size_t small_allocated;
uint64_t small_nmalloc, small_ndalloc; uint64_t small_nmalloc, small_ndalloc;
@ -312,6 +312,8 @@ stats_arena_print(void (*write4)(void *, const char *, const char *,
size_t large_allocated; size_t large_allocated;
uint64_t large_nmalloc, large_ndalloc; uint64_t large_nmalloc, large_ndalloc;
CTL_GET("arenas.pagesize", &pagesize, size_t);
CTL_I_GET("stats.arenas.0.pactive", &pactive, size_t); CTL_I_GET("stats.arenas.0.pactive", &pactive, size_t);
CTL_I_GET("stats.arenas.0.pdirty", &pdirty, size_t); CTL_I_GET("stats.arenas.0.pdirty", &pdirty, size_t);
CTL_I_GET("stats.arenas.0.npurge", &npurge, uint64_t); CTL_I_GET("stats.arenas.0.npurge", &npurge, uint64_t);
@ -348,6 +350,8 @@ stats_arena_print(void (*write4)(void *, const char *, const char *,
small_allocated + medium_allocated + large_allocated, small_allocated + medium_allocated + large_allocated,
small_nmalloc + medium_nmalloc + large_nmalloc, small_nmalloc + medium_nmalloc + large_nmalloc,
small_ndalloc + medium_ndalloc + large_ndalloc); small_ndalloc + medium_ndalloc + large_ndalloc);
malloc_cprintf(write4, w4opaque, "active: %12zu\n",
pactive * pagesize );
CTL_I_GET("stats.arenas.0.mapped", &mapped, size_t); CTL_I_GET("stats.arenas.0.mapped", &mapped, size_t);
malloc_cprintf(write4, w4opaque, "mapped: %12zu\n", mapped); malloc_cprintf(write4, w4opaque, "mapped: %12zu\n", mapped);
@ -415,12 +419,10 @@ stats_print(void (*write4)(void *, const char *, const char *, const char *,
bool bv; bool bv;
unsigned uv; unsigned uv;
ssize_t ssv; ssize_t ssv;
size_t sv, bsz, usz, ssz, sssz; size_t sv, bsz, ssz;
bsz = sizeof(bool); bsz = sizeof(bool);
usz = sizeof(unsigned);
ssz = sizeof(size_t); ssz = sizeof(size_t);
sssz = sizeof(ssize_t);
CTL_GET("config.debug", &bv, bool); CTL_GET("config.debug", &bv, bool);
write4(w4opaque, "Assertions ", bv ? "enabled" : "disabled", write4(w4opaque, "Assertions ", bv ? "enabled" : "disabled",
@ -538,27 +540,28 @@ stats_print(void (*write4)(void *, const char *, const char *, const char *,
#ifdef JEMALLOC_STATS #ifdef JEMALLOC_STATS
{ {
int err; int err;
size_t ssz, u64sz; size_t ssz;
size_t allocated, mapped; size_t allocated, active, mapped;
size_t chunks_current, chunks_high, swap_avail; size_t chunks_current, chunks_high, swap_avail;
uint64_t chunks_total; uint64_t chunks_total;
size_t huge_allocated; size_t huge_allocated;
uint64_t huge_nmalloc, huge_ndalloc; uint64_t huge_nmalloc, huge_ndalloc;
ssz = sizeof(size_t); ssz = sizeof(size_t);
u64sz = sizeof(uint64_t);
CTL_GET("stats.allocated", &allocated, size_t); CTL_GET("stats.allocated", &allocated, size_t);
CTL_GET("stats.active", &active, size_t);
CTL_GET("stats.mapped", &mapped, size_t); CTL_GET("stats.mapped", &mapped, size_t);
malloc_cprintf(write4, w4opaque, malloc_cprintf(write4, w4opaque,
"Allocated: %zu, mapped: %zu\n", allocated, mapped); "Allocated: %zu, active: %zu, mapped: %zu\n", allocated,
active, mapped);
/* Print chunk stats. */ /* Print chunk stats. */
CTL_GET("stats.chunks.total", &chunks_total, uint64_t); CTL_GET("stats.chunks.total", &chunks_total, uint64_t);
CTL_GET("stats.chunks.high", &chunks_high, size_t); CTL_GET("stats.chunks.high", &chunks_high, size_t);
CTL_GET("stats.chunks.current", &chunks_current, size_t); CTL_GET("stats.chunks.current", &chunks_current, size_t);
if ((err = mallctl("swap.avail", &swap_avail, &ssz, if ((err = mallctl("swap.avail", &swap_avail, &ssz, NULL, 0))
NULL, 0)) == 0) { == 0) {
size_t lg_chunk; size_t lg_chunk;
malloc_cprintf(write4, w4opaque, "chunks: nchunks " malloc_cprintf(write4, w4opaque, "chunks: nchunks "
@ -588,9 +591,7 @@ stats_print(void (*write4)(void *, const char *, const char *, const char *,
if (merged) { if (merged) {
unsigned narenas; unsigned narenas;
size_t usz;
usz = sizeof(unsigned);
CTL_GET("arenas.narenas", &narenas, unsigned); CTL_GET("arenas.narenas", &narenas, unsigned);
{ {
bool initialized[narenas]; bool initialized[narenas];
@ -617,11 +618,9 @@ stats_print(void (*write4)(void *, const char *, const char *, const char *,
if (unmerged) { if (unmerged) {
unsigned narenas; unsigned narenas;
size_t usz;
/* Print stats for each arena. */ /* Print stats for each arena. */
usz = sizeof(unsigned);
CTL_GET("arenas.narenas", &narenas, unsigned); CTL_GET("arenas.narenas", &narenas, unsigned);
{ {
bool initialized[narenas]; bool initialized[narenas];