Stats printing: Convert general arena stats to use the emitter.
This commit is contained in:
parent
4a335e0c6f
commit
e5acc35400
146
src/stats.c
146
src/stats.c
@ -797,118 +797,100 @@ stats_general_print(emitter_t *emitter, bool more) {
|
|||||||
#undef OPT_WRITE_SSIZE_T_MUTABLE
|
#undef OPT_WRITE_SSIZE_T_MUTABLE
|
||||||
#undef OPT_WRITE_CHAR_P
|
#undef OPT_WRITE_CHAR_P
|
||||||
|
|
||||||
if (json) {
|
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
|
||||||
",\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* arenas. */
|
/* arenas. */
|
||||||
if (json) {
|
/*
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
* The json output sticks arena info into an "arenas" dict; the table
|
||||||
"\t\t\"arenas\": {\n");
|
* output puts them at the top-level.
|
||||||
}
|
*/
|
||||||
|
emitter_json_dict_begin(emitter, "arenas");
|
||||||
|
|
||||||
CTL_GET("arenas.narenas", &uv, unsigned);
|
CTL_GET("arenas.narenas", &uv, unsigned);
|
||||||
if (json) {
|
emitter_kv(emitter, "narenas", "Arenas", emitter_type_unsigned, &uv);
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
|
||||||
"\t\t\t\"narenas\": %u,\n", uv);
|
|
||||||
} else {
|
|
||||||
malloc_cprintf(write_cb, cbopaque, "Arenas: %u\n", uv);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (json) {
|
/*
|
||||||
CTL_GET("arenas.dirty_decay_ms", &ssv, ssize_t);
|
* Decay settings are emitted only in json mode; in table mode, they're
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
* emitted as notes with the opt output, above.
|
||||||
"\t\t\t\"dirty_decay_ms\": %zd,\n", ssv);
|
*/
|
||||||
|
CTL_GET("arenas.dirty_decay_ms", &ssv, ssize_t);
|
||||||
|
emitter_json_kv(emitter, "dirty_decay_ms", emitter_type_ssize, &ssv);
|
||||||
|
|
||||||
CTL_GET("arenas.muzzy_decay_ms", &ssv, ssize_t);
|
CTL_GET("arenas.muzzy_decay_ms", &ssv, ssize_t);
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
emitter_json_kv(emitter, "muzzy_decay_ms", emitter_type_ssize, &ssv);
|
||||||
"\t\t\t\"muzzy_decay_ms\": %zd,\n", ssv);
|
|
||||||
}
|
|
||||||
|
|
||||||
CTL_GET("arenas.quantum", &sv, size_t);
|
CTL_GET("arenas.quantum", &sv, size_t);
|
||||||
if (json) {
|
emitter_kv(emitter, "quantum", "Quantum size", emitter_type_size, &sv);
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
|
||||||
"\t\t\t\"quantum\": %zu,\n", sv);
|
|
||||||
} else {
|
|
||||||
malloc_cprintf(write_cb, cbopaque, "Quantum size: %zu\n", sv);
|
|
||||||
}
|
|
||||||
|
|
||||||
CTL_GET("arenas.page", &sv, size_t);
|
CTL_GET("arenas.page", &sv, size_t);
|
||||||
if (json) {
|
emitter_kv(emitter, "page", "Page size", emitter_type_size, &sv);
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
|
||||||
"\t\t\t\"page\": %zu,\n", sv);
|
|
||||||
} else {
|
|
||||||
malloc_cprintf(write_cb, cbopaque, "Page size: %zu\n", sv);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (je_mallctl("arenas.tcache_max", (void *)&sv, &ssz, NULL, 0) == 0) {
|
if (je_mallctl("arenas.tcache_max", (void *)&sv, &ssz, NULL, 0) == 0) {
|
||||||
if (json) {
|
emitter_kv(emitter, "tcache_max",
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
"Maximum thread-cached size class", emitter_type_size, &sv);
|
||||||
"\t\t\t\"tcache_max\": %zu,\n", sv);
|
|
||||||
} else {
|
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
|
||||||
"Maximum thread-cached size class: %zu\n", sv);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (json) {
|
unsigned nbins;
|
||||||
unsigned nbins, nlextents, i;
|
CTL_GET("arenas.nbins", &nbins, unsigned);
|
||||||
|
emitter_kv(emitter, "nbins", "Number of bin size classes",
|
||||||
|
emitter_type_unsigned, &nbins);
|
||||||
|
|
||||||
CTL_GET("arenas.nbins", &nbins, unsigned);
|
unsigned nhbins;
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
CTL_GET("arenas.nhbins", &nhbins, unsigned);
|
||||||
"\t\t\t\"nbins\": %u,\n", nbins);
|
emitter_kv(emitter, "nhbins", "Number of thread-cache bin size classes",
|
||||||
|
emitter_type_unsigned, &nhbins);
|
||||||
|
|
||||||
CTL_GET("arenas.nhbins", &uv, unsigned);
|
/*
|
||||||
malloc_cprintf(write_cb, cbopaque, "\t\t\t\"nhbins\": %u,\n",
|
* We do enough mallctls in a loop that we actually want to omit them
|
||||||
uv);
|
* (not just omit the printing).
|
||||||
|
*/
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
if (emitter->output == emitter_output_json) {
|
||||||
"\t\t\t\"bin\": [\n");
|
emitter_json_arr_begin(emitter, "bin");
|
||||||
for (i = 0; i < nbins; i++) {
|
for (unsigned i = 0; i < nbins; i++) {
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
emitter_json_arr_obj_begin(emitter);
|
||||||
"\t\t\t\t{\n");
|
|
||||||
|
|
||||||
CTL_M2_GET("arenas.bin.0.size", i, &sv, size_t);
|
CTL_M2_GET("arenas.bin.0.size", i, &sv, size_t);
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
emitter_json_kv(emitter, "size", emitter_type_size,
|
||||||
"\t\t\t\t\t\"size\": %zu,\n", sv);
|
&sv);
|
||||||
|
|
||||||
CTL_M2_GET("arenas.bin.0.nregs", i, &u32v, uint32_t);
|
CTL_M2_GET("arenas.bin.0.nregs", i, &u32v, uint32_t);
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
emitter_json_kv(emitter, "nregs", emitter_type_uint32,
|
||||||
"\t\t\t\t\t\"nregs\": %"FMTu32",\n", u32v);
|
&u32v);
|
||||||
|
|
||||||
CTL_M2_GET("arenas.bin.0.slab_size", i, &sv, size_t);
|
CTL_M2_GET("arenas.bin.0.slab_size", i, &sv, size_t);
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
emitter_json_kv(emitter, "slab_size", emitter_type_size,
|
||||||
"\t\t\t\t\t\"slab_size\": %zu\n", sv);
|
&sv);
|
||||||
|
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
emitter_json_arr_obj_end(emitter);
|
||||||
"\t\t\t\t}%s\n", (i + 1 < nbins) ? "," : "");
|
|
||||||
}
|
}
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
emitter_json_arr_end(emitter); /* Close "bin". */
|
||||||
"\t\t\t],\n");
|
}
|
||||||
|
|
||||||
CTL_GET("arenas.nlextents", &nlextents, unsigned);
|
unsigned nlextents;
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
CTL_GET("arenas.nlextents", &nlextents, unsigned);
|
||||||
"\t\t\t\"nlextents\": %u,\n", nlextents);
|
emitter_kv(emitter, "nlextents", "Number of large size classes",
|
||||||
|
emitter_type_unsigned, &nlextents);
|
||||||
|
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
if (emitter->output == emitter_output_json) {
|
||||||
"\t\t\t\"lextent\": [\n");
|
emitter_json_arr_begin(emitter, "lextent");
|
||||||
for (i = 0; i < nlextents; i++) {
|
for (unsigned i = 0; i < nlextents; i++) {
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
emitter_json_arr_obj_begin(emitter);
|
||||||
"\t\t\t\t{\n");
|
|
||||||
|
|
||||||
CTL_M2_GET("arenas.lextent.0.size", i, &sv, size_t);
|
CTL_M2_GET("arenas.lextent.0.size", i, &sv, size_t);
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
emitter_json_kv(emitter, "size", emitter_type_size,
|
||||||
"\t\t\t\t\t\"size\": %zu\n", sv);
|
&sv);
|
||||||
|
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
emitter_json_arr_obj_end(emitter);
|
||||||
"\t\t\t\t}%s\n", (i + 1 < nlextents) ? "," : "");
|
|
||||||
}
|
}
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
emitter_json_arr_end(emitter); /* Close "lextent". */
|
||||||
"\t\t\t]\n");
|
}
|
||||||
|
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
emitter_json_dict_end(emitter); /* Close "arenas" */
|
||||||
"\t\t}%s\n", (config_prof || more) ? "," : "");
|
|
||||||
|
if (json) {
|
||||||
|
if (more || config_prof) {
|
||||||
|
malloc_cprintf(write_cb, cbopaque, ",\n");
|
||||||
|
} else {
|
||||||
|
malloc_cprintf(write_cb, cbopaque, "\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* prof. */
|
/* prof. */
|
||||||
|
Loading…
Reference in New Issue
Block a user