Revert previous change, for now

This commit is contained in:
Justin Ethier 2016-04-12 23:44:13 -04:00
parent 0de7c6b98b
commit 8d8ce71c92
2 changed files with 31 additions and 29 deletions

54
gc.c
View file

@ -382,32 +382,34 @@ int gc_grow_heap(gc_heap *h, size_t size, size_t chunk_size)
size_t cur_size, new_size; size_t cur_size, new_size;
gc_heap *h_last, *h_new; gc_heap *h_last, *h_new;
pthread_mutex_lock(&heap_lock); pthread_mutex_lock(&heap_lock);
// TODO: experiment with // Compute size of new heap page
// 1) growing heap gradually using a fibonnaci sequence growth // experimental code for growing heap gradually using fibonnaci sequence.
// 2) cap at HEAP_SIZE // but with boyer benchmarks there is more thrashing with this method,
// 3) allocate larger pages if heap aligned size is > page size? // 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; // size_t prev_size = 0;
h_last = h; // new_size = 0;
while (h_last->next) { // h_last = h;
if (new_size < HEAP_SIZE){ // while (h_last->next) {
new_size = prev_size + h_last->size; // if (new_size < HEAP_SIZE){
prev_size = h_last->size; // new_size = prev_size + h_last->size;
} else { // prev_size = h_last->size;
new_size = HEAP_SIZE; // } else {
} // new_size = HEAP_SIZE;
h_last = h_last->next; // }
} // h_last = h_last->next;
if (new_size == 0) // }
new_size = h_last->size; // if (new_size == 0)
//fprintf(stderr, "Growing heap new page size = %zu\n", new_size); // new_size = h_last->size;
} // //fprintf(stderr, "Growing heap new page size = %zu\n", new_size);
// OLD code: // }
// h_last = gc_heap_last(h); h_last = gc_heap_last(h);
// cur_size = h_last->size; cur_size = h_last->size;
// new_size = cur_size; //gc_heap_align(((cur_size > size) ? cur_size : size) * 2); new_size = cur_size; //gc_heap_align(((cur_size > size) ? cur_size : size) * 2);
// END TODO // 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
h_new = gc_heap_create(new_size, h_last->max_size, chunk_size); h_new = gc_heap_create(new_size, h_last->max_size, chunk_size);
h_last->next = h_new; h_last->next = h_new;
pthread_mutex_unlock(&heap_lock); pthread_mutex_unlock(&heap_lock);

View file

@ -166,9 +166,9 @@ void gc_init_heap(long heap_size)
{ {
Cyc_heap = malloc(sizeof(gc_heap_root)); Cyc_heap = malloc(sizeof(gc_heap_root));
Cyc_heap->heap = gc_heap_create(1 * 1024 * 1024, 0, 0); Cyc_heap->heap = gc_heap_create(heap_size, 0, 0);
Cyc_heap->small_obj_heap = gc_heap_create(1 * 1024 * 1024, 0, 0); Cyc_heap->small_obj_heap = gc_heap_create(heap_size, 0, 0);
Cyc_heap->medium_obj_heap = gc_heap_create(1 * 1024 * 1024, 0, 0); Cyc_heap->medium_obj_heap = gc_heap_create(heap_size, 0, 0);
if (!ck_hs_init(&symbol_table, if (!ck_hs_init(&symbol_table,
CK_HS_MODE_OBJECT | CK_HS_MODE_SPMC, CK_HS_MODE_OBJECT | CK_HS_MODE_SPMC,