mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-06-20 19:05:38 +03:00
Add extent serial numbers.
Add extent serial numbers and use them where appropriate as a sort key that is higher priority than address, so that the allocation policy prefers older extents. This resolves #147.
This commit is contained in:
parent
c0a667112c
commit
a38acf716e
7 changed files with 126 additions and 35 deletions
12
src/base.c
12
src/base.c
|
|
@ -5,6 +5,7 @@
|
|||
/* Data. */
|
||||
|
||||
static malloc_mutex_t base_mtx;
|
||||
static size_t base_extent_sn_next;
|
||||
static extent_heap_t base_avail[NSIZES];
|
||||
static extent_t *base_extents;
|
||||
static size_t base_allocated;
|
||||
|
|
@ -37,6 +38,14 @@ base_extent_dalloc(tsdn_t *tsdn, extent_t *extent)
|
|||
base_extents = extent;
|
||||
}
|
||||
|
||||
static void
|
||||
base_extent_init(extent_t *extent, void *addr, size_t size)
|
||||
{
|
||||
size_t sn = atomic_add_zu(&base_extent_sn_next, 1) - 1;
|
||||
|
||||
extent_init(extent, NULL, addr, size, 0, sn, true, true, true, false);
|
||||
}
|
||||
|
||||
static extent_t *
|
||||
base_extent_alloc(tsdn_t *tsdn, size_t minsize)
|
||||
{
|
||||
|
|
@ -74,7 +83,7 @@ base_extent_alloc(tsdn_t *tsdn, size_t minsize)
|
|||
base_resident += PAGE_CEILING(nsize);
|
||||
}
|
||||
}
|
||||
extent_init(extent, NULL, addr, esize, 0, true, true, true, false);
|
||||
base_extent_init(extent, addr, esize);
|
||||
return (extent);
|
||||
}
|
||||
|
||||
|
|
@ -164,6 +173,7 @@ base_boot(void)
|
|||
|
||||
if (malloc_mutex_init(&base_mtx, "base", WITNESS_RANK_BASE))
|
||||
return (true);
|
||||
base_extent_sn_next = 0;
|
||||
for (i = 0; i < NSIZES; i++)
|
||||
extent_heap_new(&base_avail[i]);
|
||||
base_extents = NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue