mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-23 20:15:05 +02:00
Added GC thresholds
This commit is contained in:
parent
fa933278a3
commit
e034459e81
2 changed files with 20 additions and 5 deletions
14
gc.c
14
gc.c
|
@ -864,9 +864,10 @@ void gc_mut_cooperate(gc_thread_data *thd, int buf_len)
|
|||
// Threshold is intentially low because we have to go through an
|
||||
// entire handshake/trace/sweep cycle, ideally without growing heap.
|
||||
if (ck_pr_load_int(&gc_stage) == STAGE_RESTING &&
|
||||
(cached_heap_free_size < (cached_heap_total_size * 0.10))){
|
||||
(cached_heap_free_size < (cached_heap_total_size *
|
||||
GC_COLLECTION_THRESHOLD))){
|
||||
#if GC_DEBUG_TRACE
|
||||
fprintf(stdout, "Less than 10%% of the heap is free, initiating collector\n");
|
||||
fprintf(stdout, "Less than %f%% of the heap is free, initiating collector\n", 100.0 * GC_COLLECTION_THRESHOLD);
|
||||
#endif
|
||||
ck_pr_cas_int(&gc_stage, STAGE_RESTING, STAGE_CLEAR_OR_MARKING);
|
||||
|
||||
|
@ -1208,12 +1209,15 @@ fprintf(stderr, "DEBUG - after wait_handshake async\n");
|
|||
total_size = cached_heap_total_size; //gc_heap_total_size(gc_get_heap());
|
||||
total_free = cached_heap_free_size; //gc_heap_total_free_size(gc_get_heap());
|
||||
|
||||
if (total_free < (total_size * 0.10)) {
|
||||
//TODO: want stats on how much of each heap page is used
|
||||
while (total_free < (total_size * GC_FREE_THRESHOLD)) {
|
||||
#if GC_DEBUG_TRACE
|
||||
fprintf(stdout, "Less than 10%% of the heap is free, growing it\n",
|
||||
total_free, total_size);
|
||||
fprintf(stdout, "Less than %f%% of the heap is free, growing it\n",
|
||||
100.0 * GC_FREE_THRESHOLD);
|
||||
#endif
|
||||
gc_grow_heap(gc_get_heap(), 0, 0);
|
||||
total_size = cached_heap_total_size;
|
||||
total_free = cached_heap_free_size;
|
||||
}
|
||||
#if GC_DEBUG_TRACE
|
||||
fprintf(stderr, "sweep done, total_size = %zu, total_free = %d, freed = %d, max_freed = %d, elapsed = %ld\n",
|
||||
|
|
|
@ -31,6 +31,17 @@
|
|||
// Size of a "page" on the heap (the second generation), in bytes.
|
||||
#define HEAP_SIZE (10 * 1024 * 1024)
|
||||
|
||||
/////////////////////////////
|
||||
// Major GC tuning parameters
|
||||
|
||||
// Start GC cycle if % heap space free below this percentage
|
||||
#define GC_COLLECTION_THRESHOLD 0.05
|
||||
|
||||
// After major GC, grow the heap so at least this percentage is free
|
||||
#define GC_FREE_THRESHOLD 0.40
|
||||
// END GC tuning
|
||||
/////////////////////////////
|
||||
|
||||
// Number of functions to save for printing call history
|
||||
#define MAX_STACK_TRACES 10
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue