MCPcopy Create free account
hub / github.com/F-Stack/f-stack / tcache_boot

Function tcache_boot

app/redis-6.2.6/deps/jemalloc/src/tcache.c:651–696  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

649}
650
651bool
652tcache_boot(tsdn_t *tsdn) {
653 /* If necessary, clamp opt_lg_tcache_max. */
654 if (opt_lg_tcache_max < 0 || (ZU(1) << opt_lg_tcache_max) <
655 SMALL_MAXCLASS) {
656 tcache_maxclass = SMALL_MAXCLASS;
657 } else {
658 tcache_maxclass = (ZU(1) << opt_lg_tcache_max);
659 }
660
661 if (malloc_mutex_init(&tcaches_mtx, "tcaches", WITNESS_RANK_TCACHES,
662 malloc_mutex_rank_exclusive)) {
663 return true;
664 }
665
666 nhbins = sz_size2index(tcache_maxclass) + 1;
667
668 /* Initialize tcache_bin_info. */
669 tcache_bin_info = (cache_bin_info_t *)base_alloc(tsdn, b0get(), nhbins
670 * sizeof(cache_bin_info_t), CACHELINE);
671 if (tcache_bin_info == NULL) {
672 return true;
673 }
674 stack_nelms = 0;
675 unsigned i;
676 for (i = 0; i < NBINS; i++) {
677 if ((bin_infos[i].nregs << 1) <= TCACHE_NSLOTS_SMALL_MIN) {
678 tcache_bin_info[i].ncached_max =
679 TCACHE_NSLOTS_SMALL_MIN;
680 } else if ((bin_infos[i].nregs << 1) <=
681 TCACHE_NSLOTS_SMALL_MAX) {
682 tcache_bin_info[i].ncached_max =
683 (bin_infos[i].nregs << 1);
684 } else {
685 tcache_bin_info[i].ncached_max =
686 TCACHE_NSLOTS_SMALL_MAX;
687 }
688 stack_nelms += tcache_bin_info[i].ncached_max;
689 }
690 for (; i < nhbins; i++) {
691 tcache_bin_info[i].ncached_max = TCACHE_NSLOTS_LARGE;
692 stack_nelms += tcache_bin_info[i].ncached_max;
693 }
694
695 return false;
696}
697
698void
699tcache_prefork(tsdn_t *tsdn) {

Callers 1

Calls 4

malloc_mutex_initFunction · 0.85
sz_size2indexFunction · 0.85
base_allocFunction · 0.85
b0getFunction · 0.85

Tested by

no test coverage detected