wingo pushed a commit to branch wip-whippet
in repository guile.

commit 7885ea1037c421e81f9e3edcc2856fabe1070257
Author: Andy Wingo <wi...@igalia.com>
AuthorDate: Tue Jan 21 21:09:25 2025 +0100

    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.
---
 src/nofl-space.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/nofl-space.h b/src/nofl-space.h
index a7ee4881b..66aa0ac62 100644
--- a/src/nofl-space.h
+++ b/src/nofl-space.h
@@ -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;

Reply via email to