Stats printing: Move emitter cutoff point into stats_arena_print.

This commit is contained in:
David Goldblatt 2018-03-05 13:03:22 -08:00 committed by David Goldblatt
parent cbde666d9a
commit a6ef061c43

View File

@ -465,8 +465,8 @@ stats_arena_mutexes_print(void (*write_cb)(void *, const char *),
} }
static void static void
stats_arena_print(void (*write_cb)(void *, const char *), void *cbopaque, stats_arena_print(emitter_t *emitter, unsigned i, bool bins, bool large,
bool json, unsigned i, bool bins, bool large, bool mutex) { bool mutex) {
unsigned nthreads; unsigned nthreads;
const char *dss; const char *dss;
ssize_t dirty_decay_ms, muzzy_decay_ms; ssize_t dirty_decay_ms, muzzy_decay_ms;
@ -481,6 +481,11 @@ stats_arena_print(void (*write_cb)(void *, const char *), void *cbopaque,
size_t tcache_bytes; size_t tcache_bytes;
uint64_t uptime; uint64_t uptime;
/* These should be removed once the emitter conversion is done. */
void (*write_cb)(void *, const char *) = emitter->write_cb;
void *cbopaque = emitter->cbopaque;
bool json = (emitter->output == emitter_output_json);
if (json) { if (json) {
malloc_cprintf(write_cb, cbopaque, "\n"); malloc_cprintf(write_cb, cbopaque, "\n");
} }
@ -996,10 +1001,6 @@ stats_print_helper(emitter_t *emitter, bool merged, bool destroyed,
* These should be deleted. We keep them around for a while, to aid in * These should be deleted. We keep them around for a while, to aid in
* the transition to the emitter code. * the transition to the emitter code.
*/ */
void (*write_cb)(void *, const char *) = emitter->write_cb;
void *cbopaque = emitter->cbopaque;
bool json = (emitter->output == emitter_output_json);
size_t allocated, active, metadata, metadata_thp, resident, mapped, size_t allocated, active, metadata, metadata_thp, resident, mapped,
retained; retained;
size_t num_background_threads; size_t num_background_threads;
@ -1114,8 +1115,8 @@ stats_print_helper(emitter_t *emitter, bool merged, bool destroyed,
/* Print merged arena stats. */ /* Print merged arena stats. */
emitter_table_printf(emitter, "Merged arenas stats:\n"); emitter_table_printf(emitter, "Merged arenas stats:\n");
emitter_json_dict_begin(emitter, "merged"); emitter_json_dict_begin(emitter, "merged");
stats_arena_print(write_cb, cbopaque, json, stats_arena_print(emitter, MALLCTL_ARENAS_ALL, bins,
MALLCTL_ARENAS_ALL, bins, large, mutex); large, mutex);
emitter_json_dict_end(emitter); /* Close "merged". */ emitter_json_dict_end(emitter); /* Close "merged". */
} }
@ -1125,9 +1126,8 @@ stats_print_helper(emitter_t *emitter, bool merged, bool destroyed,
emitter_table_printf(emitter, emitter_table_printf(emitter,
"Destroyed arenas stats:\n"); "Destroyed arenas stats:\n");
emitter_json_dict_begin(emitter, "destroyed"); emitter_json_dict_begin(emitter, "destroyed");
stats_arena_print(write_cb, cbopaque, json, stats_arena_print(emitter, MALLCTL_ARENAS_DESTROYED,
MALLCTL_ARENAS_DESTROYED, bins, large, bins, large, mutex);
mutex);
emitter_json_dict_end(emitter); /* Close "destroyed". */ emitter_json_dict_end(emitter); /* Close "destroyed". */
} }
@ -1142,8 +1142,7 @@ stats_print_helper(emitter_t *emitter, bool merged, bool destroyed,
arena_ind_str); arena_ind_str);
emitter_table_printf(emitter, emitter_table_printf(emitter,
"arenas[%s]:\n", arena_ind_str); "arenas[%s]:\n", arena_ind_str);
stats_arena_print(write_cb, stats_arena_print(emitter, i, bins,
cbopaque, json, i, bins,
large, mutex); large, mutex);
/* Close "<arena-ind>". */ /* Close "<arena-ind>". */
emitter_json_dict_end(emitter); emitter_json_dict_end(emitter);