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

Function prof_log_bt_index

deps/jemalloc/src/prof.c:364–405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

362}
363
364static size_t
365prof_log_bt_index(tsd_t *tsd, prof_bt_t *bt) {
366 assert(prof_logging_state == prof_logging_state_started);
367 malloc_mutex_assert_owner(tsd_tsdn(tsd), &log_mtx);
368
369 prof_bt_node_t dummy_node;
370 dummy_node.bt = *bt;
371 prof_bt_node_t *node;
372
373 /* See if this backtrace is already cached in the table. */
374 if (ckh_search(&log_bt_node_set, (void *)(&dummy_node),
375 (void **)(&node), NULL)) {
376 size_t sz = offsetof(prof_bt_node_t, vec) +
377 (bt->len * sizeof(void *));
378 prof_bt_node_t *new_node = (prof_bt_node_t *)
379 iallocztm(tsd_tsdn(tsd), sz, sz_size2index(sz), false, NULL,
380 true, arena_get(TSDN_NULL, 0, true), true);
381 if (log_bt_first == NULL) {
382 log_bt_first = new_node;
383 log_bt_last = new_node;
384 } else {
385 log_bt_last->next = new_node;
386 log_bt_last = new_node;
387 }
388
389 new_node->next = NULL;
390 new_node->index = log_bt_index;
391 /*
392 * Copy the backtrace: bt is inside a tdata or gctx, which
393 * might die before prof_log_stop is called.
394 */
395 new_node->bt.len = bt->len;
396 memcpy(new_node->vec, bt->vec, bt->len * sizeof(void *));
397 new_node->bt.vec = new_node->vec;
398
399 log_bt_index++;
400 ckh_insert(tsd, &log_bt_node_set, (void *)new_node, NULL);
401 return new_node->index;
402 } else {
403 return node->index;
404 }
405}
406static size_t
407prof_log_thr_index(tsd_t *tsd, uint64_t thr_uid, const char *name) {
408 assert(prof_logging_state == prof_logging_state_started);

Callers 1

prof_try_logFunction · 0.85

Calls 7

ckh_searchFunction · 0.70
ckh_insertFunction · 0.70
tsd_tsdnFunction · 0.50
iallocztmFunction · 0.50
sz_size2indexFunction · 0.50
arena_getFunction · 0.50

Tested by

no test coverage detected