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 [...] @ 0x5f86da8 0x5f5a1dc [...] 0x29e4d4e 0xa200316 0xabb2988 [...]
t*: 13: 6688 [0: 0] t*: 13: 6688 [0: 0]
t3: 12: 6496 [0: ] t3: 12: 6496 [0: 0]
t99: 1: 192 [0: 0] t99: 1: 192 [0: 0]
[...] [...]

View File

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