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

Function base_extent_bump_alloc_post

deps/jemalloc/src/base.c:197–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195}
196
197static void
198base_extent_bump_alloc_post(base_t *base, extent_t *extent, size_t gap_size,
199 void *addr, size_t size) {
200 if (extent_bsize_get(extent) > 0) {
201 /*
202 * Compute the index for the largest size class that does not
203 * exceed extent's size.
204 */
205 szind_t index_floor =
206 sz_size2index(extent_bsize_get(extent) + 1) - 1;
207 extent_heap_insert(&base->avail[index_floor], extent);
208 }
209
210 if (config_stats) {
211 base->allocated += size;
212 /*
213 * Add one PAGE to base_resident for every page boundary that is
214 * crossed by the new allocation. Adjust n_thp similarly when
215 * metadata_thp is enabled.
216 */
217 base->resident += PAGE_CEILING((uintptr_t)addr + size) -
218 PAGE_CEILING((uintptr_t)addr - gap_size);
219 assert(base->allocated <= base->resident);
220 assert(base->resident <= base->mapped);
221 if (metadata_thp_madvise() && (opt_metadata_thp ==
222 metadata_thp_always || base->auto_thp_switched)) {
223 base->n_thp += (HUGEPAGE_CEILING((uintptr_t)addr + size)
224 - HUGEPAGE_CEILING((uintptr_t)addr - gap_size)) >>
225 LG_HUGEPAGE;
226 assert(base->mapped >= base->n_thp << LG_HUGEPAGE);
227 }
228 }
229}
230
231static void *
232base_extent_bump_alloc(base_t *base, extent_t *extent, size_t size,

Callers 2

base_extent_bump_allocFunction · 0.70
base_newFunction · 0.70

Calls 3

metadata_thp_madviseFunction · 0.85
extent_bsize_getFunction · 0.50
sz_size2indexFunction · 0.50

Tested by

no test coverage detected