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

Function tcache_bin_flush_large

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

Source from the content-addressed store, hash-verified

186}
187
188void
189tcache_bin_flush_large(tsd_t *tsd, cache_bin_t *tbin, szind_t binind,
190 unsigned rem, tcache_t *tcache) {
191 bool merged_stats = false;
192
193 assert(binind < nhbins);
194 assert((cache_bin_sz_t)rem <= tbin->ncached);
195
196 arena_t *arena = tcache->arena;
197 assert(arena != NULL);
198 unsigned nflush = tbin->ncached - rem;
199 VARIABLE_ARRAY(extent_t *, item_extent, nflush);
200 /* Look up extent once per item. */
201 for (unsigned i = 0 ; i < nflush; i++) {
202 item_extent[i] = iealloc(tsd_tsdn(tsd), *(tbin->avail - 1 - i));
203 }
204
205 while (nflush > 0) {
206 /* Lock the arena associated with the first object. */
207 extent_t *extent = item_extent[0];
208 arena_t *locked_arena = extent_arena_get(extent);
209 UNUSED bool idump;
210
211 if (config_prof) {
212 idump = false;
213 }
214
215 malloc_mutex_lock(tsd_tsdn(tsd), &locked_arena->large_mtx);
216 for (unsigned i = 0; i < nflush; i++) {
217 void *ptr = *(tbin->avail - 1 - i);
218 assert(ptr != NULL);
219 extent = item_extent[i];
220 if (extent_arena_get(extent) == locked_arena) {
221 large_dalloc_prep_junked_locked(tsd_tsdn(tsd),
222 extent);
223 }
224 }
225 if ((config_prof || config_stats) && locked_arena == arena) {
226 if (config_prof) {
227 idump = arena_prof_accum(tsd_tsdn(tsd), arena,
228 tcache->prof_accumbytes);
229 tcache->prof_accumbytes = 0;
230 }
231 if (config_stats) {
232 merged_stats = true;
233 arena_stats_large_nrequests_add(tsd_tsdn(tsd),
234 &arena->stats, binind,
235 tbin->tstats.nrequests);
236 tbin->tstats.nrequests = 0;
237 }
238 }
239 malloc_mutex_unlock(tsd_tsdn(tsd), &locked_arena->large_mtx);
240
241 unsigned ndeferred = 0;
242 for (unsigned i = 0; i < nflush; i++) {
243 void *ptr = *(tbin->avail - 1 - i);
244 extent = item_extent[i];
245 assert(ptr != NULL && extent != NULL);

Callers 3

tcache_event_hardFunction · 0.85
tcache_flush_cacheFunction · 0.85
tcache_dalloc_largeFunction · 0.85

Calls 12

ieallocFunction · 0.85
tsd_tsdnFunction · 0.85
extent_arena_getFunction · 0.85
malloc_mutex_lockFunction · 0.85
arena_prof_accumFunction · 0.85
malloc_mutex_unlockFunction · 0.85
large_dalloc_finishFunction · 0.85
prof_idumpFunction · 0.85
arena_decay_ticksFunction · 0.85
memmoveFunction · 0.50

Tested by

no test coverage detected