123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018-2022 Tarides <contact@tarides.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)(* Determines the policy used to determine whether to add new
objects to Irmin's index whenever they are exported to the
data file. *)typeindexing_strategy=[`Minimal(* only newly-exported commit objects are added to the index *)|`Always(* all newly-exported objects are added to the index *)]typet={verbosity:[`Default|`Info|`Debug];index_log_size:int;lru_size:int;auto_flush:int;indexing_strategy:indexing_strategy;}(* Caps the number of entries stored in the Irmin's index. As a
trade-off, increasing this value will delay index merges, and thus,
make them more expensive in terms of disk usage, memory usage and
computation time.*)letindex_log_size=2_500_000(* Caps the number of entries stored in the Irmin's LRU cache. As a
trade-off, increasing this value will increase the memory
consumption.*)letlru_size=15_000(* This limit ensures that no trees with more than [auto_flush]
mutations can exist in memory, bounding the memory usage of a
single commit performed by a read-write process. As a trade-off,
the intermediate flushed trees to the store might be unused and
will have to be garbage collected later on to save space. *)letauto_flush=10_000letdefault={verbosity=`Default;index_log_size;lru_size;auto_flush;indexing_strategy=`Minimal;}letmax_verbosityab=match(a,b)with|`Debug,_|_,`Debug->`Debug|`Info,_|_,`Info->`Info|_->`Defaultletv=matchUnix.getenv"TEZOS_CONTEXT"with|exceptionNot_found->default|v->List.fold_left(funaccs->matchString.trimswith|"v"|"verbose"->{accwithverbosity=max_verbosityacc.verbosity`Info}|"vv"->{accwithverbosity=`Debug}|v->(matchString.split'='v|>List.mapString.trimwith|["index-log-size";n]->(matchint_of_string_optnwith|None->Fmt.epr"[WARNING] Trying to convert %s into an integer for \
index-log-size, but the conversion failed. Using \
default settings."n;acc|Somev->{accwithindex_log_size=v})|["lru-size";n]->(matchint_of_string_optnwith|None->Fmt.epr"[WARNING] Trying to convert %s into an integer for \
lru-size, but the conversion failed. Using default \
settings."n;acc|Somev->{accwithlru_size=v})|["auto-flush";n]->(matchint_of_string_optnwith|None->Fmt.epr"[WARNING] Trying to convert %s into an integer for \
auto-flush, but the conversion failed. Using default \
settings."n;acc|Somev->{accwithauto_flush=v})|["indexing-strategy";n]->(matchnwith|"always"->{accwithindexing_strategy=`Always}|"minimal"->{accwithindexing_strategy=`Minimal}|x->Fmt.epr"[WARNING] Unable to parse indexing strategy '%s'. \
Expected one of { 'always', 'minimal' }."x;acc)|unknown::_->Fmt.epr"[WARNING] Unknow option %s detected in the environment \
variable TEZOS_CONTEXT."unknown;acc|[]->Fmt.epr"[WARNING] Empty string detected in the environment \
variable TEZOS_CONTEXT.";acc))default(String.split','v)