From 157812741083f8c690719a4a9dd96057c7b6859b Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Tue, 12 Apr 2016 22:17:32 -0400 Subject: [PATCH] Grow heap more slowly --- gc.c | 42 ++++++++++++++++++++++-------------------- runtime.c | 8 ++++---- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/gc.c b/gc.c index 9eb41e49..91fd712b 100644 --- a/gc.c +++ b/gc.c @@ -385,26 +385,28 @@ int gc_grow_heap(gc_heap *h, int heap_type, size_t size, size_t chunk_size) // but with boyer benchmarks there is more thrashing with this method, // so for now it is not used. If it is used again, the initial heaps will // need to start at a lower size (EG 1 MB). -// { -// size_t prev_size = 0; -// new_size = 0; -// h_last = h; -// while (h_last->next) { -// if (new_size < HEAP_SIZE){ -// new_size = prev_size + h_last->size; -// prev_size = h_last->size; -// } else { -// new_size = HEAP_SIZE; -// } -// h_last = h_last->next; -// } -// if (new_size == 0) -// new_size = h_last->size; -// //fprintf(stderr, "Growing heap new page size = %zu\n", new_size); -// } - h_last = gc_heap_last(h); - cur_size = h_last->size; - new_size = cur_size; //gc_heap_align(((cur_size > size) ? cur_size : size) * 2); + { + size_t prev_size = 0 * 1024 * 1024; + new_size = 0; + h_last = h; + while (h_last->next) { + if (new_size < HEAP_SIZE){ + new_size = prev_size + h_last->size; + prev_size = h_last->size; + } else { + new_size = HEAP_SIZE; + } + h_last = h_last->next; + } + if (new_size == 0) + new_size = prev_size + h_last->size; +//#if GC_DEBUG_TRACE + fprintf(stderr, "Growing heap %d new page size = %zu\n", heap_type, new_size); +//#endif + } +// h_last = gc_heap_last(h); +// cur_size = h_last->size; +// new_size = cur_size; //gc_heap_align(((cur_size > size) ? cur_size : size) * 2); // allocate larger pages if size will not fit on the page //new_size = gc_heap_align(((cur_size > size) ? cur_size : size)); // Done with computing new page size diff --git a/runtime.c b/runtime.c index b9929bc9..b42f3f91 100644 --- a/runtime.c +++ b/runtime.c @@ -164,11 +164,11 @@ static bool set_insert(ck_hs_t *hs, const void *value) void gc_init_heap(long heap_size) { - + size_t initial_heap_size = 1 * 1024 * 1024; Cyc_heap = malloc(sizeof(gc_heap_root)); - Cyc_heap->heap = gc_heap_create(HEAP_REST, heap_size, 0, 0); - Cyc_heap->small_obj_heap = gc_heap_create(HEAP_SM, heap_size, 0, 0); - Cyc_heap->medium_obj_heap = gc_heap_create(HEAP_MED, heap_size, 0, 0); + Cyc_heap->heap = gc_heap_create(HEAP_REST, initial_heap_size, 0, 0); + Cyc_heap->small_obj_heap = gc_heap_create(HEAP_SM, initial_heap_size, 0, 0); + Cyc_heap->medium_obj_heap = gc_heap_create(HEAP_MED, initial_heap_size, 0, 0); if (!ck_hs_init(&symbol_table, CK_HS_MODE_OBJECT | CK_HS_MODE_SPMC,