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

Function prof_log_thr_index

deps/jemalloc/src/prof.c:406–441  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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);
409 malloc_mutex_assert_owner(tsd_tsdn(tsd), &log_mtx);
410
411 prof_thr_node_t dummy_node;
412 dummy_node.thr_uid = thr_uid;
413 prof_thr_node_t *node;
414
415 /* See if this thread is already cached in the table. */
416 if (ckh_search(&log_thr_node_set, (void *)(&dummy_node),
417 (void **)(&node), NULL)) {
418 size_t sz = offsetof(prof_thr_node_t, name) + strlen(name) + 1;
419 prof_thr_node_t *new_node = (prof_thr_node_t *)
420 iallocztm(tsd_tsdn(tsd), sz, sz_size2index(sz), false, NULL,
421 true, arena_get(TSDN_NULL, 0, true), true);
422 if (log_thr_first == NULL) {
423 log_thr_first = new_node;
424 log_thr_last = new_node;
425 } else {
426 log_thr_last->next = new_node;
427 log_thr_last = new_node;
428 }
429
430 new_node->next = NULL;
431 new_node->index = log_thr_index;
432 new_node->thr_uid = thr_uid;
433 strcpy(new_node->name, name);
434
435 log_thr_index++;
436 ckh_insert(tsd, &log_thr_node_set, (void *)new_node, NULL);
437 return new_node->index;
438 } else {
439 return node->index;
440 }
441}
442
443static void
444prof_try_log(tsd_t *tsd, const void *ptr, size_t usize, prof_tctx_t *tctx) {

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