aboutsummaryrefslogtreecommitdiff
path: root/toplevel
diff options
context:
space:
mode:
authorEmilio Jesus Gallego Arias2020-09-16 22:20:13 +0200
committerEmilio Jesus Gallego Arias2020-11-16 15:44:42 +0100
commit6a6069d55f0be157ff177150594fabcbc4b1f283 (patch)
treeda0609afecff04a95824697499a7f45f464b7510 /toplevel
parentfb186f25abeb0565bb6e238345f0c5147b697322 (diff)
[gc] Set GC policy as best-fit in OCaml >= 4.10.0
Closes #11277 ; the `space_overhead` parameter has been selected for maximum speedup, in some cases it could also increase memory consumption. Please use `OCAMLRUNPARAM` to tune it and report back your experiments.
Diffstat (limited to 'toplevel')
-rw-r--r--toplevel/coqtop.ml17
1 files changed, 14 insertions, 3 deletions
diff --git a/toplevel/coqtop.ml b/toplevel/coqtop.ml
index bbcfcc4826..d0d50aee70 100644
--- a/toplevel/coqtop.ml
+++ b/toplevel/coqtop.ml
@@ -149,6 +149,18 @@ let print_query opts = function
heap increment and the GC pressure coefficient.
*)
+let set_gc_policy () =
+ Gc.set { (Gc.get ()) with
+ Gc.minor_heap_size = 32*1024*1024 (* 32Mwords x 8 bytes/word = 256Mb *)
+ ; Gc.space_overhead = 120
+ }
+
+let set_gc_best_fit () =
+ Gc.set { (Gc.get ()) with
+ Gc.allocation_policy = 2 (* best-fit *)
+ ; Gc.space_overhead = 200
+ }
+
let init_gc () =
try
(* OCAMLRUNPARAM environment variable is set.
@@ -160,9 +172,8 @@ let init_gc () =
(* OCAMLRUNPARAM environment variable is not set.
* In this case, we put in place our preferred configuration.
*)
- Gc.set { (Gc.get ()) with
- Gc.minor_heap_size = 32*1024*1024; (* 32Mwords x 8 bytes/word = 256Mb *)
- Gc.space_overhead = 120}
+ set_gc_policy ();
+ if Coq_config.caml_version_nums >= [4;10;0] then set_gc_best_fit () else ()
let init_process () =
(* Coq's init process, phase 1: