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

Function cache_bin_alloc_easy

deps/jemalloc/include/jemalloc/internal/cache_bin.h:87–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85}
86
87JEMALLOC_ALWAYS_INLINE void *
88cache_bin_alloc_easy(cache_bin_t *bin, bool *success) {
89 void *ret;
90
91 bin->ncached--;
92
93 /*
94 * Check for both bin->ncached == 0 and ncached < low_water
95 * in a single branch.
96 */
97 if (unlikely(bin->ncached <= bin->low_water)) {
98 bin->low_water = bin->ncached;
99 if (bin->ncached == -1) {
100 bin->ncached = 0;
101 *success = false;
102 return NULL;
103 }
104 }
105
106 /*
107 * success (instead of ret) should be checked upon the return of this
108 * function. We avoid checking (ret == NULL) because there is never a
109 * null stored on the avail stack (which is unknown to the compiler),
110 * and eagerly checking ret would cause pipeline stall (waiting for the
111 * cacheline).
112 */
113 *success = true;
114 ret = *(bin->avail - (bin->ncached + 1));
115
116 return ret;
117}
118
119JEMALLOC_ALWAYS_INLINE bool
120cache_bin_dalloc_easy(cache_bin_t *bin, cache_bin_info_t *bin_info, void *ptr) {

Callers 4

JEMALLOC_ATTRFunction · 0.85
tcache_alloc_small_hardFunction · 0.85
tcache_alloc_smallFunction · 0.85
tcache_alloc_largeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected