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

Function tcache_bin_flush_large

deps/jemalloc/src/tcache.c:229–338  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227}
228
229void
230tcache_bin_flush_large(tsd_t *tsd, cache_bin_t *tbin, szind_t binind,
231 unsigned rem, tcache_t *tcache) {
232 bool merged_stats = false;
233
234 assert(binind < nhbins);
235 assert((cache_bin_sz_t)rem <= tbin->ncached);
236
237 arena_t *tcache_arena = tcache->arena;
238 assert(tcache_arena != NULL);
239 unsigned nflush = tbin->ncached - rem;
240 VARIABLE_ARRAY(extent_t *, item_extent, nflush);
241
242#ifndef JEMALLOC_EXTRA_SIZE_CHECK
243 /* Look up extent once per item. */
244 for (unsigned i = 0 ; i < nflush; i++) {
245 item_extent[i] = iealloc(tsd_tsdn(tsd), *(tbin->avail - 1 - i));
246 }
247#else
248 tbin_extents_lookup_size_check(tsd_tsdn(tsd), tbin, binind, nflush,
249 item_extent);
250#endif
251 while (nflush > 0) {
252 /* Lock the arena associated with the first object. */
253 extent_t *extent = item_extent[0];
254 unsigned locked_arena_ind = extent_arena_ind_get(extent);
255 arena_t *locked_arena = arena_get(tsd_tsdn(tsd),
256 locked_arena_ind, false);
257 bool idump;
258
259 if (config_prof) {
260 idump = false;
261 }
262
263 bool lock_large = !arena_is_auto(locked_arena);
264 if (lock_large) {
265 malloc_mutex_lock(tsd_tsdn(tsd), &locked_arena->large_mtx);
266 }
267 for (unsigned i = 0; i < nflush; i++) {
268 void *ptr = *(tbin->avail - 1 - i);
269 assert(ptr != NULL);
270 extent = item_extent[i];
271 if (extent_arena_ind_get(extent) == locked_arena_ind) {
272 large_dalloc_prep_junked_locked(tsd_tsdn(tsd),
273 extent);
274 }
275 }
276 if ((config_prof || config_stats) &&
277 (locked_arena == tcache_arena)) {
278 if (config_prof) {
279 idump = arena_prof_accum(tsd_tsdn(tsd),
280 tcache_arena, tcache->prof_accumbytes);
281 tcache->prof_accumbytes = 0;
282 }
283 if (config_stats) {
284 merged_stats = true;
285 arena_stats_large_flush_nrequests_add(
286 tsd_tsdn(tsd), &tcache_arena->stats, binind,

Callers 3

tcache_event_hardFunction · 0.70
tcache_flush_cacheFunction · 0.70
tcache_dalloc_largeFunction · 0.50

Calls 14

extent_arena_ind_getFunction · 0.85
large_dalloc_finishFunction · 0.70
prof_idumpFunction · 0.70
ieallocFunction · 0.50
tsd_tsdnFunction · 0.50
arena_getFunction · 0.50
arena_is_autoFunction · 0.50
malloc_mutex_lockFunction · 0.50
arena_prof_accumFunction · 0.50

Tested by

no test coverage detected