123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210(*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)openCmdlinerletocaml_section="OCAML RUNTIME PARAMETERS"letbacktrace~default=letdoc="Trigger the printing of a stack backtrace when an uncaught exception \
aborts the unikernel."inletdoc=Arg.info~docs:ocaml_section~docv:"BOOL"~doc["backtrace"]inArg.(value&optbooldefaultdoc)letrandomize_hashtables~default=letdoc="Turn on randomization of all hash tables by default."inletdoc=Arg.info~docs:ocaml_section~docv:"BOOL"~doc["randomize-hashtables"]inArg.(value&optbooldefaultdoc)letpolicy_of_int=function|0->`Next_fit|1->`First_fit|2->`Best_fit|_->assertfalseletint_of_policy=function`Next_fit->0|`First_fit->1|`Best_fit->2letallocation_policyd=letpolicy=Arg.enum[("next-fit",`Next_fit);("first-fit",`First_fit);("best-fit",`Best_fit);]inletdoc="The policy used for allocating in the OCaml heap. Possible values are: \
$(i,next-fit), $(i,first-fit), $(i,best-fit). Best-fit is only supported \
since OCaml 4.10."inletdoc=Arg.info~docs:ocaml_section~docv:"ALLOCATION"~doc["allocation-policy"]inArg.(value&optpolicy(policy_of_intd.Gc.allocation_policy)doc)letminor_heap_sized=letdoc="The size of the minor heap (in words)."inletdoc=Arg.info~docs:ocaml_section~docv:"WORDS"~doc["minor-heap-size"]inArg.(value&optintd.Gc.minor_heap_sizedoc)letmajor_heap_incrementd=letdoc="The size increment for the major heap (in words). If less than or equal \
1000, it is a percentage of the current heap size. If more than 1000, it \
is a fixed number of words."inletdoc=Arg.info~docs:ocaml_section~docv:"PERCENT/WORDS"~doc["major-heap-increment"]inArg.(value&optintd.Gc.major_heap_incrementdoc)letspace_overheadd=letdoc="The percentage of live data of wasted memory, due to GC does not \
immediately collect unreachable blocks. The major GC speed is computed \
from this parameter, it will work more if smaller."inletdoc=Arg.info~docs:ocaml_section~docv:"PERCENT"~doc["space-overhead"]inArg.(value&optintd.Gc.space_overheaddoc)letmax_space_overheadd=letdoc="Heap compaction is triggered when the estimated amount of wasted memory \
exceeds this (percentage of live data). If above 1000000, compaction is \
never triggered."inletdoc=Arg.info~docs:ocaml_section~docv:"PERCENT"~doc["max-space-overhead"]inArg.(value&optintd.Gc.max_overheaddoc)letgc_verbosityd=letdoc="GC messages on standard error output. Sum of flags. Check GC module \
documentation for details."inletdoc=Arg.info~docs:ocaml_section~docv:"VERBOSITY"~doc["gc-verbosity"]inArg.(value&optintd.Gc.verbosedoc)letgc_window_sized=letdoc="The size of the window used by the major GC for smoothing out variations \
in its workload. Between 1 and 50."inletdoc=Arg.info~docs:ocaml_section~docv:"INT"~doc["gc-window-size"]inArg.(value&optintd.Gc.window_sizedoc)letcustom_major_ratiod=letdoc="Target ratio of floating garbage to major heap size for out-of-heap \
memory held by custom values."inletdoc=Arg.info~docs:ocaml_section~docv:"RATIO"~doc["custom-major-ratio"]inArg.(value&optintd.Gc.custom_minor_ratiodoc)letcustom_minor_ratiod=letdoc="Bound on floating garbage for out-of-heap memory held by custom values in \
the minor heap."inletdoc=Arg.info~docs:ocaml_section~docv:"RATIO"~doc["custom-minor-ratio"]inArg.(value&optintd.Gc.custom_minor_ratiodoc)letcustom_minor_max_sized=letdoc="Maximum amount of out-of-heap memory for each custom value allocated in \
the minor heap."inletdoc=Arg.info~docs:ocaml_section~docv:"BYTES"~doc["custom-minor-max-size"]inArg.(value&optintd.Gc.custom_minor_max_sizedoc)letstack_limitd=letdoc="The maximum size of the fiber stacks (in words)."inletdoc=Arg.info~docs:ocaml_section~docv:"WORDS"~doc["stack-limit"]inArg.(value&optintd.Gc.stack_limitdoc)letgc_control~default=letfminor_heap_sizemajor_heap_incrementspace_overheadverbosemax_overheadstack_limitallocation_policywindow_sizecustom_major_ratiocustom_minor_ratiocustom_minor_max_size=letallocation_policy=int_of_policyallocation_policyin{Gc.minor_heap_size;major_heap_increment;space_overhead;verbose;max_overhead;stack_limit;allocation_policy;window_size;custom_major_ratio;custom_minor_ratio;custom_minor_max_size;}inTerm.(constf$minor_heap_sizedefault$major_heap_incrementdefault$space_overheaddefault$gc_verbositydefault$max_space_overheaddefault$stack_limitdefault$allocation_policydefault$gc_window_sizedefault$custom_major_ratiodefault$custom_minor_ratiodefault$custom_minor_max_sizedefault)letsetup?backtrace:(b=Somefalse)?randomize_hashtables:(r=Somefalse)?gc_control:(c=Some(Gc.get()))()=letfbacktracerandomize_hashtablesgc_control=let()=matchbacktracewithNone->()|Someb->Printexc.record_backtracebinlet()=matchrandomize_hashtableswith|None|Somefalse->()|Sometrue->Hashtbl.randomize()inlet()=matchgc_controlwithNone->()|Somec->Gc.setcin()inletsomec=Term.(constOption.some$c)inletnone=Term.constNoneinletfoldfd=Option.fold~none~some:(fund->some(f~default:d))dinletb=foldbacktracebinletr=foldrandomize_hashtablesrinletc=foldgc_controlcinTerm.(constf$b$r$c)