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.
This commit is contained in:
Justin Ethier 2017-01-12 14:37:48 +00:00
parent 32cbed2b73
commit 33e55c3cce
2 changed files with 5 additions and 3 deletions

6
gc.c
View file

@ -266,7 +266,7 @@ gc_heap *gc_heap_free(gc_heap *page, gc_heap *prev_page)
return page; return page;
} }
#if GC_DEBUG_TRACE #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 #endif
prev_page->next = page->next; 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 // 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 // off to the side and only free them if there is enough free space
// remaining without them. // 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; unsigned int h_size = h->size;
h = gc_heap_free(h, prev_h); h = gc_heap_free(h, prev_h);
cached_heap_free_sizes[heap_type] -= h_size; cached_heap_free_sizes[heap_type] -= h_size;

View file

@ -34,7 +34,7 @@
// Parameters for size of a "page" on the heap (the second generation GC), in bytes. // 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 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 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 // Major GC tuning parameters