1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-27 21:40:34 +02:00

nofl: Prevent needless expansion

Releasing memory proceeds until there is (-NOFL_BLOCK_SIZE,0] bytes to
release; we should only expand when the number of bytes to reacquire is
large enough.
This commit is contained in:
Andy Wingo 2025-01-21 21:09:25 +01:00
parent 2a51399896
commit 7885ea1037

View file

@ -1770,7 +1770,7 @@ static void
nofl_space_expand(struct nofl_space *space, size_t bytes) {
double overhead = ((double)NOFL_META_BLOCKS_PER_SLAB) / NOFL_BLOCKS_PER_SLAB;
ssize_t to_acquire = -nofl_space_maybe_reacquire_memory(space, bytes);
if (to_acquire <= 0) return;
if (to_acquire < NOFL_BLOCK_SIZE) return;
to_acquire *= (1 + overhead);
size_t reserved = align_up(to_acquire, NOFL_SLAB_SIZE);
size_t nslabs = reserved / NOFL_SLAB_SIZE;