increemntal GC: compact when a major GC is forced early

This change further defends against fragmentation when
incremental mode isn't working well.
This commit is contained in:
Matthew Flatt 2015-12-04 16:15:07 -05:00
parent b5131321d7
commit e44926fcee
2 changed files with 6 additions and 3 deletions

View File

@ -2015,7 +2015,7 @@ inline static void master_set_max_size(NewGC *gc)
inline static void reset_nursery(NewGC *gc) inline static void reset_nursery(NewGC *gc)
{ {
uintptr_t new_gen0_size; uintptr_t new_gen0_size;
new_gen0_size = NUM((GEN0_SIZE_FACTOR * (float)gc->memory_in_use) + GEN0_SIZE_ADDITION); new_gen0_size = NUM((GEN0_SIZE_FACTOR * (float)gc->memory_in_use) + GEN0_SIZE_ADDITION);
if ((new_gen0_size > GEN0_MAX_SIZE) if ((new_gen0_size > GEN0_MAX_SIZE)
|| (gc->memory_in_use > GEN0_MAX_SIZE)) /* => overflow */ || (gc->memory_in_use > GEN0_MAX_SIZE)) /* => overflow */
@ -4833,7 +4833,7 @@ inline static void do_heap_compact(NewGC *gc)
int tic_tock = gc->num_major_collects % 2; int tic_tock = gc->num_major_collects % 2;
/* incremental mode disables old-generation compaction: */ /* incremental mode disables old-generation compaction: */
if (gc->started_incremental) if (gc->started_incremental && !gc->compact_even_incremental)
return; return;
mmu_prep_for_compaction(gc->mmu); mmu_prep_for_compaction(gc->mmu);
@ -5975,8 +5975,10 @@ static void garbage_collect(NewGC *gc, int force_full, int no_full, int switchin
if (gc->full_needed_for_finalization && gc->gc_full) if (gc->full_needed_for_finalization && gc->gc_full)
gc->full_needed_for_finalization= 0; gc->full_needed_for_finalization= 0;
if (gc->gc_full) if (gc->gc_full) {
gc->compact_even_incremental = !gc->finishing_incremental;
gc->finishing_incremental = 0; gc->finishing_incremental = 0;
}
#ifdef GC_DEBUG_PAGES #ifdef GC_DEBUG_PAGES
if (gc->gc_full == 1) { if (gc->gc_full == 1) {

View File

@ -219,6 +219,7 @@ typedef struct NewGC {
unsigned char during_backpointer :1; unsigned char during_backpointer :1;
unsigned char incremental_requested :1; unsigned char incremental_requested :1;
unsigned char high_fragmentation :1; unsigned char high_fragmentation :1;
unsigned char compact_even_incremental :1;
/* blame the child */ /* blame the child */
unsigned int doing_memory_accounting :1; unsigned int doing_memory_accounting :1;