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

Function extents_insert_locked

deps/jemalloc/src/extent.c:339–368  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

337}
338
339static void
340extents_insert_locked(tsdn_t *tsdn, extents_t *extents, extent_t *extent) {
341 malloc_mutex_assert_owner(tsdn, &extents->mtx);
342 assert(extent_state_get(extent) == extents->state);
343
344 size_t size = extent_size_get(extent);
345 size_t psz = extent_size_quantize_floor(size);
346 pszind_t pind = sz_psz2ind(psz);
347 if (extent_heap_empty(&extents->heaps[pind])) {
348 bitmap_unset(extents->bitmap, &extents_bitmap_info,
349 (size_t)pind);
350 }
351 extent_heap_insert(&extents->heaps[pind], extent);
352
353 if (config_stats) {
354 extents_stats_add(extents, pind, size);
355 }
356
357 extent_list_append(&extents->lru, extent);
358 size_t npages = size >> LG_PAGE;
359 /*
360 * All modifications to npages hold the mutex (as asserted above), so we
361 * don't need an atomic fetch-add; we can get by with a load followed by
362 * a store.
363 */
364 size_t cur_extents_npages =
365 atomic_load_zu(&extents->npages, ATOMIC_RELAXED);
366 atomic_store_zu(&extents->npages, cur_extents_npages + npages,
367 ATOMIC_RELAXED);
368}
369
370static void
371extents_remove_locked(tsdn_t *tsdn, extents_t *extents, extent_t *extent) {

Callers 2

extent_deactivate_lockedFunction · 0.70

Calls 8

extents_stats_addFunction · 0.85
extent_state_getFunction · 0.50
extent_size_getFunction · 0.50
sz_psz2indFunction · 0.50
bitmap_unsetFunction · 0.50
extent_list_appendFunction · 0.50

Tested by

no test coverage detected