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

Function tcache_event_hard

deps/jemalloc/src/tcache.c:40–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40void
41tcache_event_hard(tsd_t *tsd, tcache_t *tcache) {
42 szind_t binind = tcache->next_gc_bin;
43
44 cache_bin_t *tbin;
45 if (binind < SC_NBINS) {
46 tbin = tcache_small_bin_get(tcache, binind);
47 } else {
48 tbin = tcache_large_bin_get(tcache, binind);
49 }
50 if (tbin->low_water > 0) {
51 /*
52 * Flush (ceiling) 3/4 of the objects below the low water mark.
53 */
54 if (binind < SC_NBINS) {
55 tcache_bin_flush_small(tsd, tcache, tbin, binind,
56 tbin->ncached - tbin->low_water + (tbin->low_water
57 >> 2));
58 /*
59 * Reduce fill count by 2X. Limit lg_fill_div such that
60 * the fill count is always at least 1.
61 */
62 cache_bin_info_t *tbin_info = &tcache_bin_info[binind];
63 if ((tbin_info->ncached_max >>
64 (tcache->lg_fill_div[binind] + 1)) >= 1) {
65 tcache->lg_fill_div[binind]++;
66 }
67 } else {
68 tcache_bin_flush_large(tsd, tbin, binind, tbin->ncached
69 - tbin->low_water + (tbin->low_water >> 2), tcache);
70 }
71 } else if (tbin->low_water < 0) {
72 /*
73 * Increase fill count by 2X for small bins. Make sure
74 * lg_fill_div stays greater than 0.
75 */
76 if (binind < SC_NBINS && tcache->lg_fill_div[binind] > 1) {
77 tcache->lg_fill_div[binind]--;
78 }
79 }
80 tbin->low_water = tbin->ncached;
81
82 tcache->next_gc_bin++;
83 if (tcache->next_gc_bin == nhbins) {
84 tcache->next_gc_bin = 0;
85 }
86}
87
88void *
89tcache_alloc_small_hard(tsdn_t *tsdn, arena_t *arena, tcache_t *tcache,

Callers 1

tcache_eventFunction · 0.50

Calls 2

tcache_bin_flush_smallFunction · 0.70
tcache_bin_flush_largeFunction · 0.70

Tested by

no test coverage detected