Stats printing: move non-mutex arena stats to the emitter.
Another step in the conversion process. The mutex is a little different, because we we want to emit it as an array.
This commit is contained in:
parent
8076b28721
commit
9e1846b004
91
src/stats.c
91
src/stats.c
@ -965,39 +965,40 @@ stats_print_helper(emitter_t *emitter, bool merged, bool destroyed,
|
|||||||
background_thread_run_interval = 0;
|
background_thread_run_interval = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (json) {
|
/* Generic global stats. */
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
emitter_json_dict_begin(emitter, "stats");
|
||||||
"\t\t\"stats\": {\n");
|
emitter_json_kv(emitter, "allocated", emitter_type_size, &allocated);
|
||||||
|
emitter_json_kv(emitter, "active", emitter_type_size, &active);
|
||||||
|
emitter_json_kv(emitter, "metadata", emitter_type_size, &metadata);
|
||||||
|
emitter_json_kv(emitter, "metadata_thp", emitter_type_size,
|
||||||
|
&metadata_thp);
|
||||||
|
emitter_json_kv(emitter, "resident", emitter_type_size, &resident);
|
||||||
|
emitter_json_kv(emitter, "mapped", emitter_type_size, &mapped);
|
||||||
|
emitter_json_kv(emitter, "retained", emitter_type_size, &retained);
|
||||||
|
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
emitter_table_printf(emitter, "Allocated: %zu, active: %zu, "
|
||||||
"\t\t\t\"allocated\": %zu,\n", allocated);
|
"metadata: %zu (n_thp %zu), resident: %zu, mapped: %zu, "
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
"retained: %zu\n", allocated, active, metadata, metadata_thp,
|
||||||
"\t\t\t\"active\": %zu,\n", active);
|
resident, mapped, retained);
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
|
||||||
"\t\t\t\"metadata\": %zu,\n", metadata);
|
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
|
||||||
"\t\t\t\"metadata_thp\": %zu,\n", metadata_thp);
|
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
|
||||||
"\t\t\t\"resident\": %zu,\n", resident);
|
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
|
||||||
"\t\t\t\"mapped\": %zu,\n", mapped);
|
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
|
||||||
"\t\t\t\"retained\": %zu,\n", retained);
|
|
||||||
|
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
/* Background thread stats. */
|
||||||
"\t\t\t\"background_thread\": {\n");
|
emitter_json_dict_begin(emitter, "background_thread");
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
emitter_json_kv(emitter, "num_threads", emitter_type_size,
|
||||||
"\t\t\t\t\"num_threads\": %zu,\n", num_background_threads);
|
&num_background_threads);
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
emitter_json_kv(emitter, "num_runs", emitter_type_uint64,
|
||||||
"\t\t\t\t\"num_runs\": %"FMTu64",\n",
|
&background_thread_num_runs);
|
||||||
background_thread_num_runs);
|
emitter_json_kv(emitter, "run_interval", emitter_type_uint64,
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
&background_thread_run_interval);
|
||||||
"\t\t\t\t\"run_interval\": %"FMTu64"\n",
|
emitter_json_dict_end(emitter); /* Close "background_thread". */
|
||||||
|
|
||||||
|
emitter_table_printf(emitter, "Background threads: %zu, "
|
||||||
|
"num_runs: %"FMTu64", run_interval: %"FMTu64" ns\n",
|
||||||
|
num_background_threads, background_thread_num_runs,
|
||||||
background_thread_run_interval);
|
background_thread_run_interval);
|
||||||
malloc_cprintf(write_cb, cbopaque, "\t\t\t}%s\n",
|
|
||||||
mutex ? "," : "");
|
|
||||||
|
|
||||||
|
if (json) {
|
||||||
if (mutex) {
|
if (mutex) {
|
||||||
|
malloc_cprintf(write_cb, cbopaque, ",\n");
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
malloc_cprintf(write_cb, cbopaque,
|
||||||
"\t\t\t\"mutexes\": {\n");
|
"\t\t\t\"mutexes\": {\n");
|
||||||
mutex_prof_global_ind_t i;
|
mutex_prof_global_ind_t i;
|
||||||
@ -1007,25 +1008,9 @@ stats_print_helper(emitter_t *emitter, bool merged, bool destroyed,
|
|||||||
"\t\t\t\t",
|
"\t\t\t\t",
|
||||||
i == mutex_prof_num_global_mutexes - 1);
|
i == mutex_prof_num_global_mutexes - 1);
|
||||||
}
|
}
|
||||||
malloc_cprintf(write_cb, cbopaque, "\t\t\t}\n");
|
malloc_cprintf(write_cb, cbopaque, "\t\t\t}");
|
||||||
}
|
}
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
|
||||||
"\t\t}%s\n", (merged || unmerged || destroyed) ? "," : "");
|
|
||||||
} else {
|
} else {
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
|
||||||
"Allocated: %zu, active: %zu, metadata: %zu (n_thp %zu),"
|
|
||||||
" resident: %zu, mapped: %zu, retained: %zu\n",
|
|
||||||
allocated, active, metadata, metadata_thp, resident, mapped,
|
|
||||||
retained);
|
|
||||||
|
|
||||||
if (have_background_thread && num_background_threads > 0) {
|
|
||||||
malloc_cprintf(write_cb, cbopaque,
|
|
||||||
"Background threads: %zu, num_runs: %"FMTu64", "
|
|
||||||
"run_interval: %"FMTu64" ns\n",
|
|
||||||
num_background_threads,
|
|
||||||
background_thread_num_runs,
|
|
||||||
background_thread_run_interval);
|
|
||||||
}
|
|
||||||
if (mutex) {
|
if (mutex) {
|
||||||
mutex_prof_global_ind_t i;
|
mutex_prof_global_ind_t i;
|
||||||
for (i = 0; i < mutex_prof_num_global_mutexes; i++) {
|
for (i = 0; i < mutex_prof_num_global_mutexes; i++) {
|
||||||
@ -1036,6 +1021,16 @@ stats_print_helper(emitter_t *emitter, bool merged, bool destroyed,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emitter_json_dict_end(emitter); /* Close "stats". */
|
||||||
|
|
||||||
|
if (json) {
|
||||||
|
if (merged || unmerged || destroyed) {
|
||||||
|
malloc_cprintf(write_cb, cbopaque, ",\n");
|
||||||
|
} else {
|
||||||
|
malloc_cprintf(write_cb, cbopaque, "\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (merged || destroyed || unmerged) {
|
if (merged || destroyed || unmerged) {
|
||||||
unsigned narenas;
|
unsigned narenas;
|
||||||
|
|
||||||
@ -1200,12 +1195,6 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
|
|||||||
|
|
||||||
if (general) {
|
if (general) {
|
||||||
stats_general_print(&emitter);
|
stats_general_print(&emitter);
|
||||||
|
|
||||||
if (json) {
|
|
||||||
if (config_stats) {
|
|
||||||
malloc_cprintf(write_cb, cbopaque, ",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (json) {
|
if (json) {
|
||||||
malloc_cprintf(write_cb, cbopaque, "\n");
|
malloc_cprintf(write_cb, cbopaque, "\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user