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

Function tcache_init

deps/jemalloc/src/tcache.c:409–440  ·  view source on GitHub ↗

Initialize auto tcache (embedded in TSD). */

Source from the content-addressed store, hash-verified

407
408/* Initialize auto tcache (embedded in TSD). */
409static void
410tcache_init(tsd_t *tsd, tcache_t *tcache, void *avail_stack) {
411 memset(&tcache->link, 0, sizeof(ql_elm(tcache_t)));
412 tcache->prof_accumbytes = 0;
413 tcache->next_gc_bin = 0;
414 tcache->arena = NULL;
415
416 ticker_init(&tcache->gc_ticker, TCACHE_GC_INCR);
417
418 size_t stack_offset = 0;
419 assert((TCACHE_NSLOTS_SMALL_MAX & 1U) == 0);
420 memset(tcache->bins_small, 0, sizeof(cache_bin_t) * SC_NBINS);
421 memset(tcache->bins_large, 0, sizeof(cache_bin_t) * (nhbins - SC_NBINS));
422 unsigned i = 0;
423 for (; i < SC_NBINS; i++) {
424 tcache->lg_fill_div[i] = 1;
425 stack_offset += tcache_bin_info[i].ncached_max * sizeof(void *);
426 /*
427 * avail points past the available space. Allocations will
428 * access the slots toward higher addresses (for the benefit of
429 * prefetch).
430 */
431 tcache_small_bin_get(tcache, i)->avail =
432 (void **)((uintptr_t)avail_stack + (uintptr_t)stack_offset);
433 }
434 for (; i < nhbins; i++) {
435 stack_offset += tcache_bin_info[i].ncached_max * sizeof(void *);
436 tcache_large_bin_get(tcache, i)->avail =
437 (void **)((uintptr_t)avail_stack + (uintptr_t)stack_offset);
438 }
439 assert(stack_offset == stack_nelms * sizeof(void *));
440}
441
442/* Initialize auto tcache (embedded in TSD). */
443bool

Callers 2

tsd_tcache_data_initFunction · 0.70
tcache_create_explicitFunction · 0.70

Calls 1

ticker_initFunction · 0.50

Tested by

no test coverage detected