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

Function stats_print

deps/jemalloc/src/stats.c:1395–1457  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1393}
1394
1395void
1396stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
1397 const char *opts) {
1398 int err;
1399 uint64_t epoch;
1400 size_t u64sz;
1401#define OPTION(o, v, d, s) bool v = d;
1402 STATS_PRINT_OPTIONS
1403#undef OPTION
1404
1405 /*
1406 * Refresh stats, in case mallctl() was called by the application.
1407 *
1408 * Check for OOM here, since refreshing the ctl cache can trigger
1409 * allocation. In practice, none of the subsequent mallctl()-related
1410 * calls in this function will cause OOM if this one succeeds.
1411 * */
1412 epoch = 1;
1413 u64sz = sizeof(uint64_t);
1414 err = je_mallctl("epoch", (void *)&epoch, &u64sz, (void *)&epoch,
1415 sizeof(uint64_t));
1416 if (err != 0) {
1417 if (err == EAGAIN) {
1418 malloc_write("<jemalloc>: Memory allocation failure in "
1419 "mallctl(\"epoch\", ...)\n");
1420 return;
1421 }
1422 malloc_write("<jemalloc>: Failure in mallctl(\"epoch\", "
1423 "...)\n");
1424 abort();
1425 }
1426
1427 if (opts != NULL) {
1428 for (unsigned i = 0; opts[i] != '\0'; i++) {
1429 switch (opts[i]) {
1430#define OPTION(o, v, d, s) case o: v = s; break;
1431 STATS_PRINT_OPTIONS
1432#undef OPTION
1433 default:;
1434 }
1435 }
1436 }
1437
1438 emitter_t emitter;
1439 emitter_init(&emitter,
1440 json ? emitter_output_json : emitter_output_table, write_cb,
1441 cbopaque);
1442 emitter_begin(&emitter);
1443 emitter_table_printf(&emitter, "___ Begin jemalloc statistics ___\n");
1444 emitter_json_object_kv_begin(&emitter, "jemalloc");
1445
1446 if (general) {
1447 stats_general_print(&emitter);
1448 }
1449 if (config_stats) {
1450 stats_print_helper(&emitter, merged, destroyed, unmerged,
1451 bins, large, mutex, extents);
1452 }

Callers 1

je_malloc_stats_printFunction · 0.70

Calls 10

emitter_initFunction · 0.85
emitter_beginFunction · 0.85
emitter_table_printfFunction · 0.85
emitter_json_object_endFunction · 0.85
emitter_endFunction · 0.85
je_mallctlFunction · 0.70
malloc_writeFunction · 0.70
stats_general_printFunction · 0.70
stats_print_helperFunction · 0.70

Tested by

no test coverage detected