MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / prof_dump_prep

Function prof_dump_prep

deps/memkind/src/jemalloc/src/prof.c:1542–1582  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1540}
1541
1542static void
1543prof_dump_prep(tsd_t *tsd, prof_tdata_t *tdata,
1544 struct prof_tdata_merge_iter_arg_s *prof_tdata_merge_iter_arg,
1545 struct prof_gctx_merge_iter_arg_s *prof_gctx_merge_iter_arg,
1546 prof_gctx_tree_t *gctxs) {
1547 size_t tabind;
1548 union {
1549 prof_gctx_t *p;
1550 void *v;
1551 } gctx;
1552
1553 prof_enter(tsd, tdata);
1554
1555 /*
1556 * Put gctx's in limbo and clear their counters in preparation for
1557 * summing.
1558 */
1559 gctx_tree_new(gctxs);
1560 for (tabind = 0; !ckh_iter(&bt2gctx, &tabind, NULL, &gctx.v);) {
1561 prof_dump_gctx_prep(tsd_tsdn(tsd), gctx.p, gctxs);
1562 }
1563
1564 /*
1565 * Iterate over tdatas, and for the non-expired ones snapshot their tctx
1566 * stats and merge them into the associated gctx's.
1567 */
1568 prof_tdata_merge_iter_arg->tsdn = tsd_tsdn(tsd);
1569 memset(&prof_tdata_merge_iter_arg->cnt_all, 0, sizeof(prof_cnt_t));
1570 malloc_mutex_lock(tsd_tsdn(tsd), &tdatas_mtx);
1571 tdata_tree_iter(&tdatas, NULL, prof_tdata_merge_iter,
1572 (void *)prof_tdata_merge_iter_arg);
1573 malloc_mutex_unlock(tsd_tsdn(tsd), &tdatas_mtx);
1574
1575 /* Merge tctx stats into gctx's. */
1576 prof_gctx_merge_iter_arg->tsdn = tsd_tsdn(tsd);
1577 prof_gctx_merge_iter_arg->leak_ngctx = 0;
1578 gctx_tree_iter(gctxs, NULL, prof_gctx_merge_iter,
1579 (void *)prof_gctx_merge_iter_arg);
1580
1581 prof_leave(tsd, tdata);
1582}
1583
1584static bool
1585prof_dump_file(tsd_t *tsd, bool propagate_err, const char *filename,

Callers 2

prof_dumpFunction · 0.70
prof_cnt_allFunction · 0.70

Calls 7

prof_enterFunction · 0.70
ckh_iterFunction · 0.70
prof_dump_gctx_prepFunction · 0.70
prof_leaveFunction · 0.70
tsd_tsdnFunction · 0.50
malloc_mutex_lockFunction · 0.50
malloc_mutex_unlockFunction · 0.50

Tested by

no test coverage detected