Unify printing for prof counts object

This commit is contained in:
Yinan Zhang 2020-03-30 16:48:45 -07:00
parent 5d292b5660
commit c8683bee80
2 changed files with 25 additions and 23 deletions

View File

@ -3437,7 +3437,7 @@ heap_v2/524288
[...]
@ 0x5f86da8 0x5f5a1dc [...] 0x29e4d4e 0xa200316 0xabb2988 [...]
t*: 13: 6688 [0: 0]
t3: 12: 6496 [0: ]
t3: 12: 6496 [0: 0]
t99: 1: 192 [0: 0]
[...]
@ -3448,9 +3448,9 @@ descriptions of the corresponding fields. <programlisting><![CDATA[
<heap_profile_format_version>/<mean_sample_interval>
<aggregate>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>]
[...]
<thread_3_aggregate>: <curobjs>: <curbytes>[<cumobjs>: <cumbytes>]
<thread_3_aggregate>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>]
[...]
<thread_99_aggregate>: <curobjs>: <curbytes>[<cumobjs>: <cumbytes>]
<thread_99_aggregate>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>]
[...]
@ <top_frame> <frame> [...] <frame> <frame> <frame> [...]
<backtrace_aggregate>: <curobjs>: <curbytes> [<cumobjs>: <cumbytes>]

View File

@ -573,6 +573,12 @@ prof_dump_printf(const char *format, ...) {
prof_dump_write(buf);
}
static void
prof_dump_print_cnts(const prof_cnt_t *cnts) {
prof_dump_printf("%"FMTu64": %"FMTu64" [%"FMTu64": %"FMTu64"]",
cnts->curobjs, cnts->curbytes, cnts->accumobjs, cnts->accumbytes);
}
static void
prof_tctx_merge_tdata(tsdn_t *tsdn, prof_tctx_t *tctx, prof_tdata_t *tdata) {
malloc_mutex_assert_owner(tsdn, tctx->tdata->lock);
@ -649,11 +655,9 @@ prof_tctx_dump_iter(prof_tctx_tree_t *tctxs, prof_tctx_t *tctx, void *arg) {
break;
case prof_tctx_state_dumping:
case prof_tctx_state_purgatory:
prof_dump_printf(
" t%"FMTu64": %"FMTu64": %"FMTu64" [%"FMTu64": "
"%"FMTu64"]\n", tctx->thr_uid, tctx->dump_cnts.curobjs,
tctx->dump_cnts.curbytes, tctx->dump_cnts.accumobjs,
tctx->dump_cnts.accumbytes);
prof_dump_printf(" t%"FMTu64": ", tctx->thr_uid);
prof_dump_print_cnts(&tctx->dump_cnts);
prof_dump_write("\n");
break;
default:
not_reached();
@ -820,22 +824,21 @@ prof_tdata_dump_iter(prof_tdata_tree_t *tdatas, prof_tdata_t *tdata,
return NULL;
}
prof_dump_printf(
" t%"FMTu64": %"FMTu64": %"FMTu64" [%"FMTu64": %"FMTu64"]%s%s\n",
tdata->thr_uid, tdata->cnt_summed.curobjs,
tdata->cnt_summed.curbytes, tdata->cnt_summed.accumobjs,
tdata->cnt_summed.accumbytes,
(tdata->thread_name != NULL) ? " " : "",
(tdata->thread_name != NULL) ? tdata->thread_name : "");
prof_dump_printf(" t%"FMTu64": ", tdata->thr_uid);
prof_dump_print_cnts(&tdata->cnt_summed);
if (tdata->thread_name != NULL) {
prof_dump_printf(" %s", tdata->thread_name);
}
prof_dump_write("\n");
return NULL;
}
static void
prof_dump_header_impl(tsdn_t *tsdn, const prof_cnt_t *cnt_all) {
prof_dump_printf("heap_v2/%"FMTu64"\n"
" t*: %"FMTu64": %"FMTu64" [%"FMTu64": %"FMTu64"]\n",
((uint64_t)1U << lg_prof_sample), cnt_all->curobjs,
cnt_all->curbytes, cnt_all->accumobjs, cnt_all->accumbytes);
prof_dump_printf("heap_v2/%"FMTu64"\n t*: ",
((uint64_t)1U << lg_prof_sample));
prof_dump_print_cnts(cnt_all);
prof_dump_write("\n");
malloc_mutex_lock(tsdn, &tdatas_mtx);
tdata_tree_iter(&tdatas, NULL, prof_tdata_dump_iter, NULL);
@ -864,10 +867,9 @@ prof_dump_gctx(tsdn_t *tsdn, prof_gctx_t *gctx, const prof_bt_t *bt,
prof_dump_printf(" %#"FMTxPTR, (uintptr_t)bt->vec[i]);
}
prof_dump_printf(
"\n t*: %"FMTu64": %"FMTu64" [%"FMTu64": %"FMTu64"]\n",
gctx->cnt_summed.curobjs, gctx->cnt_summed.curbytes,
gctx->cnt_summed.accumobjs, gctx->cnt_summed.accumbytes);
prof_dump_write("\n t*: ");
prof_dump_print_cnts(&gctx->cnt_summed);
prof_dump_write("\n");
tctx_tree_iter(&gctx->tctxs, NULL, prof_tctx_dump_iter,
(void *)tsdn);