Beispiel #1
0
static void
stats_arena_print(void (*write_cb)(void *, const char *), void *cbopaque,
    unsigned i, bool bins, bool large)
{
	unsigned nthreads;
	size_t page, pactive, pdirty, mapped;
	uint64_t npurge, nmadvise, purged;
	size_t small_allocated;
	uint64_t small_nmalloc, small_ndalloc, small_nrequests;
	size_t large_allocated;
	uint64_t large_nmalloc, large_ndalloc, large_nrequests;

	CTL_GET("arenas.page", &page, size_t);

	CTL_I_GET("stats.arenas.0.nthreads", &nthreads, unsigned);
	malloc_cprintf(write_cb, cbopaque,
	    "assigned threads: %u\n", nthreads);
	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.npurge", &npurge, uint64_t);
	CTL_I_GET("stats.arenas.0.nmadvise", &nmadvise, uint64_t);
	CTL_I_GET("stats.arenas.0.purged", &purged, uint64_t);
	malloc_cprintf(write_cb, cbopaque,
	    "dirty pages: %zu:%zu active:dirty, %"PRIu64" sweep%s,"
	    " %"PRIu64" madvise%s, %"PRIu64" purged\n",
	    pactive, pdirty, npurge, npurge == 1 ? "" : "s",
	    nmadvise, nmadvise == 1 ? "" : "s", purged);

	malloc_cprintf(write_cb, cbopaque,
	    "            allocated      nmalloc      ndalloc    nrequests\n");
	CTL_I_GET("stats.arenas.0.small.allocated", &small_allocated, size_t);
	CTL_I_GET("stats.arenas.0.small.nmalloc", &small_nmalloc, uint64_t);
	CTL_I_GET("stats.arenas.0.small.ndalloc", &small_ndalloc, uint64_t);
	CTL_I_GET("stats.arenas.0.small.nrequests", &small_nrequests, uint64_t);
	malloc_cprintf(write_cb, cbopaque,
	    "small:   %12zu %12"PRIu64" %12"PRIu64" %12"PRIu64"\n",
	    small_allocated, small_nmalloc, small_ndalloc, small_nrequests);
	CTL_I_GET("stats.arenas.0.large.allocated", &large_allocated, size_t);
	CTL_I_GET("stats.arenas.0.large.nmalloc", &large_nmalloc, uint64_t);
	CTL_I_GET("stats.arenas.0.large.ndalloc", &large_ndalloc, uint64_t);
	CTL_I_GET("stats.arenas.0.large.nrequests", &large_nrequests, uint64_t);
	malloc_cprintf(write_cb, cbopaque,
	    "large:   %12zu %12"PRIu64" %12"PRIu64" %12"PRIu64"\n",
	    large_allocated, large_nmalloc, large_ndalloc, large_nrequests);
	malloc_cprintf(write_cb, cbopaque,
	    "total:   %12zu %12"PRIu64" %12"PRIu64" %12"PRIu64"\n",
	    small_allocated + large_allocated,
	    small_nmalloc + large_nmalloc,
	    small_ndalloc + large_ndalloc,
	    small_nrequests + large_nrequests);
	malloc_cprintf(write_cb, cbopaque, "active:  %12zu\n", pactive * page);
	CTL_I_GET("stats.arenas.0.mapped", &mapped, size_t);
	malloc_cprintf(write_cb, cbopaque, "mapped:  %12zu\n", mapped);

	if (bins)
		stats_arena_bins_print(write_cb, cbopaque, i);
	if (large)
		stats_arena_lruns_print(write_cb, cbopaque, i);
}
Beispiel #2
0
static void
stats_arena_print(void (*write_cb)(void *, const char *), void *cbopaque,
    unsigned i, bool bins, bool large, bool huge)
{
	unsigned nthreads;
	const char *dss;
	ssize_t lg_dirty_mult;
	size_t page, pactive, pdirty, mapped;
	size_t metadata_mapped, metadata_allocated;
	uint64_t npurge, nmadvise, purged;
	size_t small_allocated;
	uint64_t small_nmalloc, small_ndalloc, small_nrequests;
	size_t large_allocated;
	uint64_t large_nmalloc, large_ndalloc, large_nrequests;
	size_t huge_allocated;
	uint64_t huge_nmalloc, huge_ndalloc, huge_nrequests;

	CTL_GET("arenas.page", &page, size_t);

	CTL_M2_GET("stats.arenas.0.nthreads", i, &nthreads, unsigned);
	malloc_cprintf(write_cb, cbopaque,
	    "assigned threads: %u\n", nthreads);
	CTL_M2_GET("stats.arenas.0.dss", i, &dss, const char *);
	malloc_cprintf(write_cb, cbopaque, "dss allocation precedence: %s\n",
	    dss);
	CTL_M2_GET("stats.arenas.0.lg_dirty_mult", i, &lg_dirty_mult, ssize_t);
	if (lg_dirty_mult >= 0) {
		malloc_cprintf(write_cb, cbopaque,
		    "min active:dirty page ratio: %u:1\n",
		    (1U << lg_dirty_mult));
	} else {
		malloc_cprintf(write_cb, cbopaque,
		    "min active:dirty page ratio: N/A\n");
	}
	CTL_M2_GET("stats.arenas.0.pactive", i, &pactive, size_t);
	CTL_M2_GET("stats.arenas.0.pdirty", i, &pdirty, size_t);
	CTL_M2_GET("stats.arenas.0.npurge", i, &npurge, uint64_t);
	CTL_M2_GET("stats.arenas.0.nmadvise", i, &nmadvise, uint64_t);
	CTL_M2_GET("stats.arenas.0.purged", i, &purged, uint64_t);
	malloc_cprintf(write_cb, cbopaque,
	    "dirty pages: %zu:%zu active:dirty, %"FMTu64" sweep%s, %"FMTu64
	    " madvise%s, %"FMTu64" purged\n", pactive, pdirty, npurge, npurge ==
	    1 ? "" : "s", nmadvise, nmadvise == 1 ? "" : "s", purged);

	malloc_cprintf(write_cb, cbopaque,
	    "                            allocated      nmalloc      ndalloc"
	    "    nrequests\n");
	CTL_M2_GET("stats.arenas.0.small.allocated", i, &small_allocated,
	    size_t);
	CTL_M2_GET("stats.arenas.0.small.nmalloc", i, &small_nmalloc, uint64_t);
	CTL_M2_GET("stats.arenas.0.small.ndalloc", i, &small_ndalloc, uint64_t);
	CTL_M2_GET("stats.arenas.0.small.nrequests", i, &small_nrequests,
	    uint64_t);
	malloc_cprintf(write_cb, cbopaque,
	    "small:                   %12zu %12"FMTu64" %12"FMTu64
	    " %12"FMTu64"\n",
	    small_allocated, small_nmalloc, small_ndalloc, small_nrequests);
	CTL_M2_GET("stats.arenas.0.large.allocated", i, &large_allocated,
	    size_t);
	CTL_M2_GET("stats.arenas.0.large.nmalloc", i, &large_nmalloc, uint64_t);
	CTL_M2_GET("stats.arenas.0.large.ndalloc", i, &large_ndalloc, uint64_t);
	CTL_M2_GET("stats.arenas.0.large.nrequests", i, &large_nrequests,
	    uint64_t);
	malloc_cprintf(write_cb, cbopaque,
	    "large:                   %12zu %12"FMTu64" %12"FMTu64
	    " %12"FMTu64"\n",
	    large_allocated, large_nmalloc, large_ndalloc, large_nrequests);
	CTL_M2_GET("stats.arenas.0.huge.allocated", i, &huge_allocated, size_t);
	CTL_M2_GET("stats.arenas.0.huge.nmalloc", i, &huge_nmalloc, uint64_t);
	CTL_M2_GET("stats.arenas.0.huge.ndalloc", i, &huge_ndalloc, uint64_t);
	CTL_M2_GET("stats.arenas.0.huge.nrequests", i, &huge_nrequests,
	    uint64_t);
	malloc_cprintf(write_cb, cbopaque,
	    "huge:                    %12zu %12"FMTu64" %12"FMTu64
	    " %12"FMTu64"\n",
	    huge_allocated, huge_nmalloc, huge_ndalloc, huge_nrequests);
	malloc_cprintf(write_cb, cbopaque,
	    "total:                   %12zu %12"FMTu64" %12"FMTu64
	    " %12"FMTu64"\n",
	    small_allocated + large_allocated + huge_allocated,
	    small_nmalloc + large_nmalloc + huge_nmalloc,
	    small_ndalloc + large_ndalloc + huge_ndalloc,
	    small_nrequests + large_nrequests + huge_nrequests);
	malloc_cprintf(write_cb, cbopaque,
	    "active:                  %12zu\n", pactive * page);
	CTL_M2_GET("stats.arenas.0.mapped", i, &mapped, size_t);
	malloc_cprintf(write_cb, cbopaque,
	    "mapped:                  %12zu\n", mapped);
	CTL_M2_GET("stats.arenas.0.metadata.mapped", i, &metadata_mapped,
	    size_t);
	CTL_M2_GET("stats.arenas.0.metadata.allocated", i, &metadata_allocated,
	    size_t);
	malloc_cprintf(write_cb, cbopaque,
	    "metadata: mapped: %zu, allocated: %zu\n",
	    metadata_mapped, metadata_allocated);

	if (bins)
		stats_arena_bins_print(write_cb, cbopaque, i);
	if (large)
		stats_arena_lruns_print(write_cb, cbopaque, i);
	if (huge)
		stats_arena_hchunks_print(write_cb, cbopaque, i);
}