1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-26 21:20:30 +02:00

mmc: Grow the heap if collection fails to find space for large alloc

For a pending large allocation, we will try to page out blocks from the
nofl space.  However sometimes we are not able to do so, especially if
evacuation is unavailable, as in a heap-conservative configuration.  In
that case, if the heap is growable, grow the heap after GC if there are
still bytes pending to page out.
This commit is contained in:
Andy Wingo 2025-05-16 22:01:55 +02:00
parent fbcdffdc62
commit b794e46635

View file

@ -531,6 +531,23 @@ compute_progress(struct gc_heap *heap, uintptr_t allocation_since_last_gc) {
return allocation_since_last_gc > nofl_space_fragmentation(nofl); return allocation_since_last_gc > nofl_space_fragmentation(nofl);
} }
static void
grow_heap_for_large_allocation_if_necessary(struct gc_heap *heap,
enum gc_collection_kind gc_kind,
int progress)
{
if (progress || heap->sizer.policy == GC_HEAP_SIZE_FIXED)
return;
struct nofl_space *nofl = heap_nofl_space(heap);
if (nofl_space_shrink (nofl, 0))
return;
ssize_t pending = nofl_space_request_release_memory(nofl, 0);
GC_ASSERT (pending > 0);
resize_heap(heap, heap->size + pending);
}
static int static int
compute_success(struct gc_heap *heap, enum gc_collection_kind gc_kind, compute_success(struct gc_heap *heap, enum gc_collection_kind gc_kind,
int progress) { int progress) {
@ -833,6 +850,7 @@ collect(struct gc_mutator *mut, enum gc_collection_kind requested_kind) {
DEBUG("--- total live bytes estimate: %zu\n", live_bytes_estimate); DEBUG("--- total live bytes estimate: %zu\n", live_bytes_estimate);
gc_heap_sizer_on_gc(heap->sizer, heap->size, live_bytes_estimate, pause_ns, gc_heap_sizer_on_gc(heap->sizer, heap->size, live_bytes_estimate, pause_ns,
resize_heap); resize_heap);
grow_heap_for_large_allocation_if_necessary(heap, gc_kind, progress);
heap->size_at_last_gc = heap->size; heap->size_at_last_gc = heap->size;
HEAP_EVENT(heap, restarting_mutators); HEAP_EVENT(heap, restarting_mutators);
allow_mutators_to_continue(heap); allow_mutators_to_continue(heap);