summaryrefslogtreecommitdiff
path: root/byterun/major_gc.c
diff options
context:
space:
mode:
Diffstat (limited to 'byterun/major_gc.c')
-rw-r--r--byterun/major_gc.c30
1 files changed, 19 insertions, 11 deletions
diff --git a/byterun/major_gc.c b/byterun/major_gc.c
index d39cd2f203..06183d5196 100644
--- a/byterun/major_gc.c
+++ b/byterun/major_gc.c
@@ -42,7 +42,8 @@ static asize_t gray_vals_size;
static int heap_is_pure; /* The heap is pure if the only gray objects
below [markhp] are also in [gray_vals]. */
unsigned long caml_allocated_words;
-double caml_extra_heap_memory;
+unsigned long caml_dependent_size, caml_dependent_allocated;
+double caml_extra_heap_resources;
unsigned long caml_fl_size_at_phase_change = 0;
extern char *caml_fl_merge; /* Defined in freelist.c. */
@@ -294,7 +295,7 @@ static void sweep_slice (long work)
*/
long caml_major_collection_slice (long howmuch)
{
- double p;
+ double p, dp;
long computed_work;
/*
Free memory at the start of the GC cycle (garbage + free list) (assumed):
@@ -304,15 +305,15 @@ long caml_major_collection_slice (long howmuch)
Assuming steady state and enforcing a constant allocation rate, then
FM is divided in 2/3 for garbage and 1/3 for free list.
G = 2 * FM / 3
- G is also the amount of memory that will be used during this slice
+ G is also the amount of memory that will be used during this cycle
(still assuming steady state).
Proportion of G consumed since the previous slice:
PH = caml_allocated_words / G
= caml_allocated_words * 3 * (100 + caml_percent_free)
/ (2 * caml_stat_heap_size * caml_percent_free)
- Proportion of extra-heap memory consumed since the previous slice:
- PE = caml_extra_heap_memory
+ Proportion of extra-heap resources consumed since the previous slice:
+ PE = caml_extra_heap_resources
Proportion of total work to do in this slice:
P = max (PH, PE)
Amount of marking work for the GC cycle:
@@ -332,11 +333,18 @@ long caml_major_collection_slice (long howmuch)
p = (double) caml_allocated_words * 3.0 * (100 + caml_percent_free)
/ Wsize_bsize (caml_stat_heap_size) / caml_percent_free / 2.0;
- if (p < caml_extra_heap_memory) p = caml_extra_heap_memory;
+ if (caml_dependent_size > 0){
+ dp = (double) caml_dependent_allocated * (100 + caml_percent_free)
+ / caml_dependent_size / caml_percent_free;
+ }else{
+ dp = 0.0;
+ }
+ if (p < dp) p = dp;
+ if (p < caml_extra_heap_resources) p = caml_extra_heap_resources;
caml_gc_message (0x40, "allocated_words = %lu\n", caml_allocated_words);
- caml_gc_message (0x40, "extra_heap_memory = %luu\n",
- (unsigned long) (caml_extra_heap_memory * 1000000));
+ caml_gc_message (0x40, "extra_heap_resources = %luu\n",
+ (unsigned long) (caml_extra_heap_resources * 1000000));
caml_gc_message (0x40, "amount of work to do = %luu\n",
(unsigned long) (p * 1000000));
@@ -362,7 +370,8 @@ long caml_major_collection_slice (long howmuch)
caml_stat_major_words += caml_allocated_words;
caml_allocated_words = 0;
- caml_extra_heap_memory = 0.0;
+ caml_dependent_allocated = 0;
+ caml_extra_heap_resources = 0.0;
return computed_work;
}
@@ -417,7 +426,6 @@ asize_t caml_round_heap_chunk_size (asize_t request)
void caml_init_major_heap (asize_t heap_size)
{
asize_t i;
- void *block;
asize_t page_table_size;
page_table_entry *page_table_block;
@@ -459,5 +467,5 @@ void caml_init_major_heap (asize_t heap_size)
gray_vals_end = gray_vals + gray_vals_size;
heap_is_pure = 1;
caml_allocated_words = 0;
- caml_extra_heap_memory = 0.0;
+ caml_extra_heap_resources = 0.0;
}