From 558c7d8257d7381f21a3d641b7997af2798bb8ac Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Tue, 5 Jul 2016 21:53:38 -0400 Subject: [PATCH] Fast-track heap page size for a large allocation --- gc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gc.c b/gc.c index 95578a39..9bc27d3b 100644 --- a/gc.c +++ b/gc.c @@ -448,8 +448,13 @@ int gc_grow_heap(gc_heap * h, int heap_type, size_t size, size_t chunk_size) } h_last = h_last->next; } - if (new_size == 0) + if (new_size == 0) { new_size = prev_size + h_last->size; + } + // Fast-track heap page size if allocating a large block + if (new_size < size && size < HEAP_SIZE) { + new_size = HEAP_SIZE; + } #if GC_DEBUG_TRACE fprintf(stderr, "Growing heap %d new page size = %zu\n", heap_type, new_size);