tcache.c (286866) | tcache.c (288090) |
---|---|
1#define JEMALLOC_TCACHE_C_ 2#include "jemalloc/internal/jemalloc_internal.h" 3 4/******************************************************************************/ 5/* Data. */ 6 7bool opt_tcache = true; 8ssize_t opt_lg_tcache_max = LG_TCACHE_MAXCLASS_DEFAULT; --- 18 unchanged lines hidden (view full) --- 27{ 28 29 return (arena_salloc(ptr, false)); 30} 31 32void 33tcache_event_hard(tsd_t *tsd, tcache_t *tcache) 34{ | 1#define JEMALLOC_TCACHE_C_ 2#include "jemalloc/internal/jemalloc_internal.h" 3 4/******************************************************************************/ 5/* Data. */ 6 7bool opt_tcache = true; 8ssize_t opt_lg_tcache_max = LG_TCACHE_MAXCLASS_DEFAULT; --- 18 unchanged lines hidden (view full) --- 27{ 28 29 return (arena_salloc(ptr, false)); 30} 31 32void 33tcache_event_hard(tsd_t *tsd, tcache_t *tcache) 34{ |
35 index_t binind = tcache->next_gc_bin; | 35 szind_t binind = tcache->next_gc_bin; |
36 tcache_bin_t *tbin = &tcache->tbins[binind]; 37 tcache_bin_info_t *tbin_info = &tcache_bin_info[binind]; 38 39 if (tbin->low_water > 0) { 40 /* 41 * Flush (ceiling) 3/4 of the objects below the low water mark. 42 */ 43 if (binind < NBINS) { --- 23 unchanged lines hidden (view full) --- 67 tcache->next_gc_bin++; 68 if (tcache->next_gc_bin == nhbins) 69 tcache->next_gc_bin = 0; 70 tcache->ev_cnt = 0; 71} 72 73void * 74tcache_alloc_small_hard(tsd_t *tsd, arena_t *arena, tcache_t *tcache, | 36 tcache_bin_t *tbin = &tcache->tbins[binind]; 37 tcache_bin_info_t *tbin_info = &tcache_bin_info[binind]; 38 39 if (tbin->low_water > 0) { 40 /* 41 * Flush (ceiling) 3/4 of the objects below the low water mark. 42 */ 43 if (binind < NBINS) { --- 23 unchanged lines hidden (view full) --- 67 tcache->next_gc_bin++; 68 if (tcache->next_gc_bin == nhbins) 69 tcache->next_gc_bin = 0; 70 tcache->ev_cnt = 0; 71} 72 73void * 74tcache_alloc_small_hard(tsd_t *tsd, arena_t *arena, tcache_t *tcache, |
75 tcache_bin_t *tbin, index_t binind) | 75 tcache_bin_t *tbin, szind_t binind) |
76{ 77 void *ret; 78 79 arena_tcache_fill_small(arena, tbin, binind, config_prof ? 80 tcache->prof_accumbytes : 0); 81 if (config_prof) 82 tcache->prof_accumbytes = 0; 83 ret = tcache_alloc_easy(tbin); 84 85 return (ret); 86} 87 88void 89tcache_bin_flush_small(tsd_t *tsd, tcache_t *tcache, tcache_bin_t *tbin, | 76{ 77 void *ret; 78 79 arena_tcache_fill_small(arena, tbin, binind, config_prof ? 80 tcache->prof_accumbytes : 0); 81 if (config_prof) 82 tcache->prof_accumbytes = 0; 83 ret = tcache_alloc_easy(tbin); 84 85 return (ret); 86} 87 88void 89tcache_bin_flush_small(tsd_t *tsd, tcache_t *tcache, tcache_bin_t *tbin, |
90 index_t binind, unsigned rem) | 90 szind_t binind, unsigned rem) |
91{ 92 arena_t *arena; 93 void *ptr; 94 unsigned i, nflush, ndeferred; 95 bool merged_stats = false; 96 97 assert(binind < NBINS); 98 assert(rem <= tbin->ncached); --- 62 unchanged lines hidden (view full) --- 161 memmove(tbin->avail, &tbin->avail[tbin->ncached - rem], 162 rem * sizeof(void *)); 163 tbin->ncached = rem; 164 if ((int)tbin->ncached < tbin->low_water) 165 tbin->low_water = tbin->ncached; 166} 167 168void | 91{ 92 arena_t *arena; 93 void *ptr; 94 unsigned i, nflush, ndeferred; 95 bool merged_stats = false; 96 97 assert(binind < NBINS); 98 assert(rem <= tbin->ncached); --- 62 unchanged lines hidden (view full) --- 161 memmove(tbin->avail, &tbin->avail[tbin->ncached - rem], 162 rem * sizeof(void *)); 163 tbin->ncached = rem; 164 if ((int)tbin->ncached < tbin->low_water) 165 tbin->low_water = tbin->ncached; 166} 167 168void |
169tcache_bin_flush_large(tsd_t *tsd, tcache_bin_t *tbin, index_t binind, | 169tcache_bin_flush_large(tsd_t *tsd, tcache_bin_t *tbin, szind_t binind, |
170 unsigned rem, tcache_t *tcache) 171{ 172 arena_t *arena; 173 void *ptr; 174 unsigned i, nflush, ndeferred; 175 bool merged_stats = false; 176 177 assert(binind < nhbins); --- 313 unchanged lines hidden (view full) --- 491} 492 493bool 494tcache_boot(void) 495{ 496 unsigned i; 497 498 /* | 170 unsigned rem, tcache_t *tcache) 171{ 172 arena_t *arena; 173 void *ptr; 174 unsigned i, nflush, ndeferred; 175 bool merged_stats = false; 176 177 assert(binind < nhbins); --- 313 unchanged lines hidden (view full) --- 491} 492 493bool 494tcache_boot(void) 495{ 496 unsigned i; 497 498 /* |
499 * If necessary, clamp opt_lg_tcache_max, now that arena_maxclass is | 499 * If necessary, clamp opt_lg_tcache_max, now that large_maxclass is |
500 * known. 501 */ 502 if (opt_lg_tcache_max < 0 || (1U << opt_lg_tcache_max) < SMALL_MAXCLASS) 503 tcache_maxclass = SMALL_MAXCLASS; | 500 * known. 501 */ 502 if (opt_lg_tcache_max < 0 || (1U << opt_lg_tcache_max) < SMALL_MAXCLASS) 503 tcache_maxclass = SMALL_MAXCLASS; |
504 else if ((1U << opt_lg_tcache_max) > arena_maxclass) 505 tcache_maxclass = arena_maxclass; | 504 else if ((1U << opt_lg_tcache_max) > large_maxclass) 505 tcache_maxclass = large_maxclass; |
506 else 507 tcache_maxclass = (1U << opt_lg_tcache_max); 508 509 nhbins = size2index(tcache_maxclass) + 1; 510 511 /* Initialize tcache_bin_info. */ 512 tcache_bin_info = (tcache_bin_info_t *)base_alloc(nhbins * 513 sizeof(tcache_bin_info_t)); --- 24 unchanged lines hidden --- | 506 else 507 tcache_maxclass = (1U << opt_lg_tcache_max); 508 509 nhbins = size2index(tcache_maxclass) + 1; 510 511 /* Initialize tcache_bin_info. */ 512 tcache_bin_info = (tcache_bin_info_t *)base_alloc(nhbins * 513 sizeof(tcache_bin_info_t)); --- 24 unchanged lines hidden --- |