From 33e55c3ccee7a21ceed3e58979b5394ecae04fac Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Thu, 12 Jan 2017 14:37:48 +0000 Subject: [PATCH] GC tweaks to avoid free/grow thrashing Attempt to prevent thrashing the GC during earley benchmark by: - Allowing a larger max page size - Only freeing huge pages. This prevents thrashing where pages are freed only to be immediately reallocated when the heap is grown after sweep. Longer term it may be necessary to allow freeing of pages by being more intelligent about things. --- gc.c | 6 ++++-- include/cyclone/types.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/gc.c b/gc.c index 08303c1d..4455dca2 100644 --- a/gc.c +++ b/gc.c @@ -266,7 +266,7 @@ gc_heap *gc_heap_free(gc_heap *page, gc_heap *prev_page) return page; } #if GC_DEBUG_TRACE - fprintf(stderr, "DEBUG freeing heap page at addr: %p\n", page); + fprintf(stderr, "DEBUG freeing heap type %d page at addr: %p\n", page->type, page); #endif prev_page->next = page->next; @@ -853,7 +853,9 @@ size_t gc_sweep(gc_heap * h, int heap_type, size_t * sum_freed_ptr) // so forth. A better solution might be to keep empty heap pages // off to the side and only free them if there is enough free space // remaining without them. - if (gc_is_heap_empty(h) && !h->newly_created){ + // + // Experimenting with only freeing huge heaps + if (h->type == HEAP_HUGE && gc_is_heap_empty(h) && !h->newly_created){ unsigned int h_size = h->size; h = gc_heap_free(h, prev_h); cached_heap_free_sizes[heap_type] -= h_size; diff --git a/include/cyclone/types.h b/include/cyclone/types.h index 8a80b361..3f947368 100644 --- a/include/cyclone/types.h +++ b/include/cyclone/types.h @@ -34,7 +34,7 @@ // Parameters for size of a "page" on the heap (the second generation GC), in bytes. #define GROW_HEAP_BY_SIZE (2 * 1024 * 1024) // Grow first page by adding this amount to it #define INITIAL_HEAP_SIZE (3 * 1024 * 1024) // Size of the first page -#define HEAP_SIZE (32 * 1024 * 1024) // Normal size of a page +#define HEAP_SIZE (377 * 1024 * 1024) // Normal size of a page ///////////////////////////// // Major GC tuning parameters