diff options
author | Damien Doligez <damien.doligez-inria.fr> | 2014-03-31 17:58:53 +0000 |
---|---|---|
committer | Damien Doligez <damien.doligez-inria.fr> | 2014-03-31 17:58:53 +0000 |
commit | 8643356b8542e0dcab358716f1e04d47b08b1a6d (patch) | |
tree | e10cc5a03f7ead69a2d4ed563cbd021df5770ef2 /byterun/gc_ctrl.c | |
parent | cd1bf4b9fc898cee2f4886ed18ddf6271ec522e8 (diff) | |
parent | 989ac0b2635443b9c0f183ee6343b663c854f4ea (diff) | |
download | ocaml-ephemeron.tar.gz |
merge with trunk at rev 14512ephemeron
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/ephemeron@14514 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'byterun/gc_ctrl.c')
-rw-r--r-- | byterun/gc_ctrl.c | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/byterun/gc_ctrl.c b/byterun/gc_ctrl.c index 84327fa289..7e61f0c1b6 100644 --- a/byterun/gc_ctrl.c +++ b/byterun/gc_ctrl.c @@ -43,10 +43,10 @@ intnat caml_stat_minor_collections = 0, caml_stat_compactions = 0, caml_stat_heap_chunks = 0; -extern uintnat caml_major_heap_increment; /* bytes; see major_gc.c */ -extern uintnat caml_percent_free; /* see major_gc.c */ -extern uintnat caml_percent_max; /* see compact.c */ -extern uintnat caml_allocation_policy; /* see freelist.c */ +extern uintnat caml_major_heap_increment; /* percent or words; see major_gc.c */ +extern uintnat caml_percent_free; /* see major_gc.c */ +extern uintnat caml_percent_max; /* see compact.c */ +extern uintnat caml_allocation_policy; /* see freelist.c */ #define Next(hp) ((hp) + Bhsize_hp (hp)) @@ -346,14 +346,6 @@ static uintnat norm_pmax (uintnat p) return p; } -static intnat norm_heapincr (uintnat i) -{ -#define Psv (Wsize_bsize (Page_size)) - i = ((i + Psv - 1) / Psv) * Psv; - if (i < Heap_chunk_min) i = Heap_chunk_min; - return i; -} - static intnat norm_minsize (intnat s) { if (s < Minor_heap_min) s = Minor_heap_min; @@ -386,11 +378,16 @@ CAMLprim value caml_gc_set(value v) caml_gc_message (0x20, "New max overhead: %d%%\n", caml_percent_max); } - newheapincr = Bsize_wsize (norm_heapincr (Long_val (Field (v, 1)))); + newheapincr = Long_val (Field (v, 1)); if (newheapincr != caml_major_heap_increment){ caml_major_heap_increment = newheapincr; - caml_gc_message (0x20, "New heap increment size: %luk bytes\n", - caml_major_heap_increment/1024); + if (newheapincr > 1000){ + caml_gc_message (0x20, "New heap increment size: %luk words\n", + caml_major_heap_increment/1024); + }else{ + caml_gc_message (0x20, "New heap increment size: %lu%%\n", + caml_major_heap_increment); + } } oldpolicy = caml_allocation_policy; caml_set_allocation_policy (Long_val (Field (v, 6))); @@ -475,17 +472,26 @@ CAMLprim value caml_gc_compaction(value v) return Val_unit; } +uintnat caml_normalize_heap_increment (uintnat i) +{ + if (i < Bsize_wsize (Heap_chunk_min)){ + i = Bsize_wsize (Heap_chunk_min); + } + return ((i + Page_size - 1) >> Page_log) << Page_log; +} + void caml_init_gc (uintnat minor_size, uintnat major_size, uintnat major_incr, uintnat percent_fr, uintnat percent_m) { - uintnat major_heap_size = Bsize_wsize (norm_heapincr (major_size)); + uintnat major_heap_size = + Bsize_wsize (caml_normalize_heap_increment (major_size)); if (caml_page_table_initialize(Bsize_wsize(minor_size) + major_heap_size)){ caml_fatal_error ("OCaml runtime error: cannot initialize page table\n"); } caml_set_minor_heap_size (Bsize_wsize (norm_minsize (minor_size))); - caml_major_heap_increment = Bsize_wsize (norm_heapincr (major_incr)); + caml_major_heap_increment = major_incr; caml_percent_free = norm_pfree (percent_fr); caml_percent_max = norm_pmax (percent_m); caml_init_major_heap (major_heap_size); @@ -495,8 +501,13 @@ void caml_init_gc (uintnat minor_size, uintnat major_size, major_heap_size / 1024); caml_gc_message (0x20, "Initial space overhead: %lu%%\n", caml_percent_free); caml_gc_message (0x20, "Initial max overhead: %lu%%\n", caml_percent_max); - caml_gc_message (0x20, "Initial heap increment: %luk bytes\n", - caml_major_heap_increment / 1024); + if (caml_major_heap_increment > 1000){ + caml_gc_message (0x20, "Initial heap increment: %luk words\n", + caml_major_heap_increment / 1024); + }else{ + caml_gc_message (0x20, "Initial heap increment: %lu%%\n", + caml_major_heap_increment); + } caml_gc_message (0x20, "Initial allocation policy: %d\n", caml_allocation_policy); } |