2 * Copyright (c) 2015, Facebook, Inc.
5 * This source code is licensed under the MIT license found in the
6 * LICENSE file in the "hack" directory of this source tree.
10 open Config_file.Getters
11 module Hack_bucket
= Bucket
13 open Option.Monad_infix
14 module Bucket
= Hack_bucket
16 module Watchman
= struct
23 sockname
: string option;
26 synchronous_timeout
: int;
31 debug_logging
= false;
33 (* buck and hgwatchman use a 10 second timeout, too *)
37 synchronous_timeout
= 120;
40 let load ~current_version ~
default config
=
44 ~
default:default.enabled
56 int_
"watchman_init_timeout" ~
default:default.init_timeout config
58 let sockname = string_opt
"watchman_sockname" config
in
61 "watchman_subscribe_v2"
62 ~
default:default.subscribe
66 let synchronous_timeout =
68 "watchman_synchronous_timeout"
69 ~
default:default.synchronous_timeout
74 "watchman_debug_logging"
75 ~
default:default.debug_logging
89 module RemoteTypeCheck
= struct
91 (* Controls the `defer_class_declaration_threshold` setting on the remote worker *)
92 declaration_threshold
: int;
93 (* A list of error phases; if, before type checking, errors in these phases
94 are present, then remote type checking will be disabled *)
95 disabled_on_errors
: Errors.phase list
;
96 (* Enables remote type check *)
98 (* A non-interactive host is, e.g., a dev host not currently associated with a user,
99 or a host used for non-interactive jobs (e.g., CI) *)
100 enabled_for_noninteractive_hosts
: bool;
101 (* Indicates how long to wait between heartbeats (in seconds) *)
102 heartbeat_period
: int;
103 load_naming_table_on_full_init
: bool;
106 (* Dictates the number of remote type checking workers *)
108 (* Indicates whether files-to-declare should be fetched by VFS
109 (see `declaration_threshold`) *)
110 prefetch_deferred_files
: bool;
111 (* If set, distributes type checking to remote workers if the number of files to
112 type check exceeds the threshold. If not set, then always checks everything locally. *)
113 recheck_threshold
: int option;
114 worker_min_log_level
: Hh_logger.Level.t
;
115 (* Indicates the size of the job below which a virtual file system should
116 be used by the remote worker *)
117 worker_vfs_checkout_threshold
: int;
118 (* File system mode used by ArtifactStore *)
119 file_system_mode
: ArtifactStore.file_system_mode
;
120 (* Max artifact size to use CAS; otherwise use everstore *)
122 (* Max artifact size to inline into transport channel *)
123 max_artifact_inline_bytes
: int;
124 (* [0.0 - 1.0] ratio that specifies how much portion of the total payload
125 should be used in remote workers initial payload. Default is 0.0 which means
126 one bucket and no special bundling for initial payload *)
127 remote_initial_payload_ratio
: float;
133 enabled_for_noninteractive_hosts
= false;
134 declaration_threshold
= 50;
135 disabled_on_errors
= [];
136 (* Indicates how long to wait between heartbeats (in seconds) *)
137 heartbeat_period
= 15;
138 load_naming_table_on_full_init
= false;
139 max_batch_size
= 25_000;
140 min_batch_size
= 5_000;
142 prefetch_deferred_files
= false;
143 recheck_threshold
= None
;
144 worker_min_log_level
= Hh_logger.Level.Info
;
145 worker_vfs_checkout_threshold
= 10_000;
146 file_system_mode
= ArtifactStore.Distributed
;
147 max_cas_bytes
= 50_000_000;
148 max_artifact_inline_bytes
= 2000;
149 remote_initial_payload_ratio
= 0.0;
152 let load ~current_version ~
default config
=
153 let declaration_threshold =
155 "remote_type_check_declaration_threshold"
156 ~
default:default.declaration_threshold
160 let file_system_mode =
161 let open ArtifactStore
in
162 let file_system_mode =
164 "remote_type_check_file_system_mode"
165 ~
default:(string_of_file_system_mode Distributed
)
168 match file_system_mode_of_string
file_system_mode with
170 | None
-> Distributed
175 "remote_type_check_max_cas_bytes"
176 ~
default:default.max_cas_bytes
180 let max_artifact_inline_bytes =
182 "remote_type_check_max_artifact_inline_bytes"
183 ~
default:default.max_artifact_inline_bytes
187 let enabled_on_errors =
189 "remote_type_check_enabled_on_errors"
192 |> List.fold ~init
:[] ~f
:(fun acc phase
->
193 match Errors.phase_of_string phase
with
194 | Some phase
-> phase
:: acc
197 let disabled_on_errors =
199 [Errors.Typing
; Errors.Decl
; Errors.Parsing
; Errors.Init
; Errors.Naming
]
202 (List.exists
enabled_on_errors ~f
:(fun enabled_phase
->
203 Errors.equal_phase enabled_phase phase
)))
205 let heartbeat_period =
207 "remote_type_check_heartbeat_period"
208 ~
default:default.heartbeat_period
212 int_
"remote_type_check_num_workers" ~
default:default.num_workers config
216 "remote_type_check_max_batch_size"
217 ~
default:default.max_batch_size
222 "remote_type_check_min_batch_size"
223 ~
default:default.min_batch_size
226 let prefetch_deferred_files =
228 "remote_type_check_prefetch_deferred_files"
229 ~
default:default.prefetch_deferred_files
233 let recheck_threshold =
234 int_opt
"remote_type_check_recheck_threshold" config
236 let remote_initial_payload_ratio =
238 "remote_type_check_remote_initial_payload_ratio"
239 ~
default:default.remote_initial_payload_ratio
242 let load_naming_table_on_full_init =
244 "remote_type_check_load_naming_table_on_full_init"
245 ~
default:default.load_naming_table_on_full_init
251 "remote_type_check_enabled"
252 ~
default:default.enabled
256 let enabled_for_noninteractive_hosts =
258 "remote_type_check_enabled_for_noninteractive_hosts"
259 ~
default:default.enabled_for_noninteractive_hosts
263 let worker_min_log_level =
265 Hh_logger.Level.of_enum_string
268 "remote_type_check_worker_min_log_level"
270 (Hh_logger.Level.to_enum_string
default.worker_min_log_level)
273 | Some level
-> level
274 | None
-> Hh_logger.Level.Debug
276 let worker_vfs_checkout_threshold =
278 "remote_type_check_worker_vfs_checkout_threshold"
279 ~
default:default.worker_vfs_checkout_threshold
283 declaration_threshold;
286 enabled_for_noninteractive_hosts;
288 load_naming_table_on_full_init;
292 prefetch_deferred_files;
294 worker_min_log_level;
295 worker_vfs_checkout_threshold;
298 max_artifact_inline_bytes;
299 remote_initial_payload_ratio;
303 module RecheckCapture
= struct
305 (* Enables recheck environment capture *)
307 (* If the error theshold is not met, then the recheck environment that
308 doesn't meet the fanout-related thresholds will not be captured. *)
309 error_threshold
: int;
310 (* We will automatically capture the recheck environment if
311 the number of files to recheck exceeds this threshold.
312 The number of rechecked files is always less than or equal to
314 fanout_threshold
: int;
315 (* We will automatically capture the recheck environment if
316 the number of rechecked files exceeds this threshold *)
317 rechecked_files_threshold
: int;
318 (* If set, determines the rate of sampling of rechecks regardless of
319 their fanout size. The error threshold would still apply.
320 NOTE: valid values fall between 0.0 (0%) and 1.0 (100%).
321 Values less than 0.0 will be interpreted as 0.0; values greater than
322 1.0 will be interpreted as 1.0 *)
323 sample_threshold
: float;
329 (* We wouldn't capture small rechecks unless they have at least
332 (* If capturing is enabled and the recheck fanout (pre-type-check)
333 meets this threshold, then we would snapshot the changed files. *)
334 fanout_threshold
= 40_000;
335 (* If the number of files actually rechecked meets this threshold
336 and we already snapshotted the changed files based on fanout
337 size or sampling, we would capture the recheck environment. *)
338 rechecked_files_threshold
= 5_000;
339 (* We wouldn't take changed files snapshots of small fanouts
340 unless they are randomly selected with the probability controlled
341 by the sample_threshold setting. By default, we don't snapshot
342 any small fanouts. *)
343 sample_threshold
= 0.0;
346 let load ~current_version ~
default config
=
349 "recheck_capture_enabled"
350 ~
default:default.enabled
354 let error_threshold =
356 "recheck_capture_error_threshold"
357 ~
default:default.error_threshold
360 let fanout_threshold =
362 "recheck_capture_fanout_threshold"
363 ~
default:default.fanout_threshold
366 let rechecked_files_threshold =
368 "recheck_capture_rechecked_files_threshold"
369 ~
default:default.rechecked_files_threshold
372 let sample_threshold =
373 let sample_threshold =
375 "recheck_capture_sample_threshold"
376 ~
default:default.sample_threshold
379 if Float.(sample_threshold > 1.0) then
381 else if Float.(sample_threshold < 0.0) then
390 rechecked_files_threshold;
395 (** Allows to typecheck only a certain quantile of the workload. *)
398 (** The number of quantiles we want.
399 If this is n, we'll divide the workload in n groups. *)
401 (** The index of the subgroup we'll process.
402 If this is i, we'll typecheck group number i out of the n groups.
403 this should be in interval [0; n] *)
407 min_log_level
: Hh_logger.Level.t
;
408 attempt_fix_credentials
: bool;
409 (** Indicates whether we attempt to fix the credentials if they're broken *)
410 log_categories
: string list
;
411 experiments
: string list
;
412 (** the list of experiments from the experiments config *)
413 experiments_config_meta
: string; (** a free-form diagnostic string *)
414 use_saved_state
: bool;
415 (** should we attempt to load saved-state? (subject to further options) *)
416 require_saved_state
: bool;
417 (** if attempting saved-state, should we fail upon failure? *)
418 load_state_natively
: bool;
419 (** make hh_server query and download saved state. *)
420 load_state_natively_64bit
: bool; (** TODO(hverr): Clean up 32-bit *)
422 (** if doing a full init, do it in 64-bit mode
423 TODO(hverr): Clean up 32-bit *)
424 load_state_natively_download_timeout
: int; (** in seconds *)
425 load_state_natively_dirty_files_timeout
: int; (** in seconds *)
426 type_decl_bucket_size
: int;
427 extend_fast_bucket_size
: int;
429 enable_fuzzy_search
: bool;
432 max_purgatory_clients
: int;
433 (** Monitor: Limit the number of clients that can sit in purgatory waiting
434 for a server to be started because we don't want this to grow unbounded. *)
435 search_chunk_size
: int;
438 can_skip_deptable
: bool;
439 (** TODO(hverr): Remove can_skip_deptable, 32-bit clean up *)
440 shm_dirs
: string list
;
441 shm_use_sharded_hashtbl
: bool;
442 shm_enable_eviction
: bool;
443 shm_max_evictable_bytes
: int;
444 max_workers
: int option;
445 max_bucket_size
: int;
446 (** max_bucket_size is the default bucket size for ALL users of MultiWorker unless they provide a specific override max_size *)
447 use_dummy_informant
: bool; (** See HhMonitorInformant. *)
448 informant_min_distance_restart
: int;
449 use_full_fidelity_parser
: bool;
450 interrupt_on_watchman
: bool;
451 interrupt_on_client
: bool;
453 prechecked_files
: bool;
454 enable_type_check_filter_files
: bool;
455 (** Let the user configure which files to type check and
456 which files to ignore. This flag is not expected to be
457 rolled out broadly, rather it is meant to be used by
460 ide_serverless
: bool; (** whether clientLsp should use serverless-ide *)
461 ide_ranked_autocomplete
: bool;
462 (** whether clientLsp should use ranked autocomplete *)
463 ide_ffp_autocomplete
: bool;
464 (** whether clientLsp should use ffp-autocomplete *)
465 ide_max_num_decls
: int; (** tuning of clientIdeDaemon local cache *)
466 ide_max_num_shallow_decls
: int; (** tuning of clientIdeDaemon local cache *)
467 ide_max_num_linearizations
: int; (** tuning of clientIdeDaemon local cache *)
468 ide_symbolindex_search_provider
: string;
469 (** like [symbolindex_search_provider] but for IDE *)
470 predeclare_ide
: bool;
471 max_typechecker_worker_memory_mb
: int option;
472 longlived_workers
: bool;
473 remote_execution
: bool;
475 hg_aware_parsing_restart_threshold
: int;
476 hg_aware_redecl_restart_threshold
: int;
477 hg_aware_recheck_restart_threshold
: int;
478 force_remote_type_check
: bool; (** forces Hulk *)
479 ide_parser_cache
: bool;
480 store_decls_in_saved_state
: bool;
481 (** When enabled, save hot class declarations (for now, specified in a special
482 file in the repository) when generating a saved state. *)
483 load_decls_from_saved_state
: bool;
484 (** When enabled, load class declarations stored in the saved state, if any, on
487 (** Size of Gc.major_slice to be performed when server is idle. 0 to disable *)
488 shallow_class_decl
: bool;
489 (** Look up class members lazily from shallow declarations instead of eagerly
490 computing folded declarations representing the entire class type. *)
491 force_shallow_decl_fanout
: bool;
492 (** Use fanout algorithm based solely on shallow decl comparison. This is the
493 default in shallow decl mode. Use this option if using folded decls. *)
494 force_load_hot_shallow_decls
: bool;
495 (** Always load hot shallow decls from saved state. *)
496 fetch_remote_old_decls
: bool;
497 (** Option to fetch old decls from remote decl store *)
498 use_hack_64_naming_table
: bool;
499 (** Load naming table from hack/64 saved state. *)
500 skip_hierarchy_checks
: bool;
501 (** Skip checks on hierarchy e.g. overrides, require extend, etc.
502 Set to true only for debugging purposes! *)
503 num_local_workers
: int option;
504 (** If None, only the type check delegate's logic will be used.
505 If the delegate fails to type check, the typing check service as a whole
507 parallel_type_checking_threshold
: int;
508 (** If the number of files to type check is fewer than this value, the files
509 will be type checked sequentially (in the master process). Otherwise,
510 the files will be type checked in parallel (in MultiWorker workers). *)
511 defer_class_declaration_threshold
: int option;
512 (** If set, defers class declarations after N lazy declarations; if not set,
513 always lazily declares classes not already in cache. *)
514 defer_class_memory_mb_threshold
: int option;
515 (** If set, defers class declaration if worker memory exceeds threshold. *)
516 prefetch_deferred_files: bool;
517 (** The whether to use the hook that prefetches files on an Eden checkout *)
518 recheck_capture
: RecheckCapture.t
;
519 (** Settings controlling how and whether we capture the recheck environment *)
520 recli_version
: string;
521 (** The version of the Remote Execution CLI tool to use *)
522 remote_nonce
: Int64.t
;
523 (** The unique identifier of a particular remote typechecking run *)
524 remote_type_check
: RemoteTypeCheck.t
;
525 (** Remote type check settings that can be changed, e.g., by GK *)
526 remote_worker_key
: string option;
527 (** If set, uses the key to fetch type checking jobs *)
528 remote_check_id
: string option;
529 (** If set, uses the check ID when logging events in the context of remove init/work *)
530 remote_version_specifier_required
: bool;
531 (** Indicates whether the remote version specifier is required for remote type check from non-prod server *)
532 remote_version_specifier
: string option;
533 (** The version of the package the remote worker is to install *)
534 remote_transport_channel
: string option;
535 (** Name of the transport channel used by remote type checking. TODO: move into remote_type_check. *)
536 naming_sqlite_path
: string option;
537 (** Enables the reverse naming table to fall back to SQLite for queries. *)
538 enable_naming_table_fallback
: bool;
539 symbolindex_search_provider
: string;
540 (** Selects a search provider for autocomplete and symbol search; see also [ide_symbolindex_search_provider] *)
541 symbolindex_quiet
: bool;
542 symbolindex_file
: string option;
543 tico_invalidate_files
: bool;
544 (** Allows hh_server to invalidate units in hhvm based on local changes *)
545 tico_invalidate_smart
: bool; (** Use finer grain hh_server dependencies *)
546 use_direct_decl_parser
: bool;
547 (** Enable use of the direct decl parser for parsing type signatures. *)
548 profile_log
: bool; (** Log per-file performance information. *)
549 profile_type_check_duration_threshold
: float;
550 (** If --profile-log, we'll record telemetry on typechecks that took longer than the threshold (in seconds). In case of profile_type_check_twice we judge by the second type check. *)
551 profile_type_check_memory_threshold_mb
: int;
552 (** If --profile-log, we'll record telemetry on any file which allocated more than this many mb on the ocaml heap. In case of profile_type_check_twice we judge by the second type check. *)
553 profile_type_check_twice
: bool;
554 (** The flag "--config profile_type_check_twice=true" causes each file to be typechecked twice in succession. If --profile-log then both times are logged. *)
555 profile_decling
: Typing_service_types.profile_decling
;
556 (** The flag "--config profile_decling=..." says what kind of instrumentation we want for each decl *)
557 profile_owner
: string option;
558 (** If --profile-log, we can use "--config profile_owner=<str>" to send an arbitrary "owner" along with the telemetry *)
559 profile_desc
: string;
560 (** If --profile-log, we can use "--config profile_desc=<str>" to send an arbitrary "desc" along with telemetry *)
561 go_to_implementation
: bool;
562 (** Allows the IDE to show the 'find all implementations' button *)
563 allow_unstable_features
: bool;
564 (** Allows unstabled features to be enabled within a file via the '__EnableUnstableFeatures' attribute *)
566 (** Whether to send errors to client as soon as they are discovered. *)
567 watchman
: Watchman.t
;
568 save_and_upload_naming_table
: bool;
569 (** If enabled, saves naming table into a temp folder and uploads it to the remote typechecker *)
570 log_from_client_when_slow_monitor_connections
: bool;
571 (** Alerts hh users what processes are using hh_server when hh_client is slow to connect. *)
572 naming_sqlite_in_hack_64
: bool;
573 (** Add sqlite naming table to hack/64 ss job *)
574 workload_quantile
: quantile
option;
575 (** Allows to typecheck only a certain quantile of the workload. *)
576 enable_disk_heap
: bool;
577 (** After reading the contents of a file from the filesystem, store them
578 in shared memory. True by default. Disabling this saves memory at the
579 risk of increasing the rate of consistency errors. *)
580 rollout_group
: string option;
581 (** A string from hh.conf, written to HackEvengLogger telemetry. Before it got
582 into here, [t], it was first used as a lookup in ServerLocalConfigKnobs.
583 Intended meaning: what class of user is running hh_server, hence what experiments
584 should they be subject to. *)
585 machine_class
: string option;
586 (** A string from hh.conf, written to HackEvengLogger telemetry. Before it got
587 into here, [t], it was first used as a lookup in ServerLocalConfigKnobs.
588 Intended meaning: what kind of hardware this machine has, hence what settings
589 for workers should be used. *)
594 min_log_level
= Hh_logger.Level.Info
;
595 attempt_fix_credentials
= false;
598 experiments_config_meta
= "";
599 force_remote_type_check
= false;
600 use_saved_state
= false;
601 require_saved_state
= false;
602 load_state_natively
= false;
603 load_state_natively_64bit
= false;
604 no_load_64bit
= false;
605 load_state_natively_download_timeout
= 60;
606 load_state_natively_dirty_files_timeout
= 200;
607 type_decl_bucket_size
= 1000;
608 extend_fast_bucket_size
= 2000;
609 enable_on_nfs
= false;
610 enable_fuzzy_search
= true;
613 max_purgatory_clients
= 400;
614 search_chunk_size
= 0;
617 can_skip_deptable
= true;
618 shm_dirs
= [GlobalConfig.shm_dir
; GlobalConfig.tmp_dir
];
619 shm_use_sharded_hashtbl
= false;
620 shm_enable_eviction
= false;
621 shm_max_evictable_bytes
= 3 * 1024 * 1024 * 1024;
623 max_bucket_size
= Bucket.max_size
();
624 use_dummy_informant
= true;
625 informant_min_distance_restart
= 100;
626 use_full_fidelity_parser
= true;
627 interrupt_on_watchman
= false;
628 interrupt_on_client
= false;
629 trace_parsing
= false;
630 prechecked_files
= false;
631 enable_type_check_filter_files
= false;
633 ide_serverless
= false;
634 ide_ranked_autocomplete
= false;
635 ide_ffp_autocomplete
= false;
636 ide_max_num_decls
= 5000;
637 ide_max_num_shallow_decls
= 10000;
638 ide_max_num_linearizations
= 10000;
639 predeclare_ide
= false;
640 max_typechecker_worker_memory_mb
= None
;
641 longlived_workers
= false;
642 remote_execution
= false;
644 hg_aware_parsing_restart_threshold
= 0;
645 hg_aware_redecl_restart_threshold
= 0;
646 hg_aware_recheck_restart_threshold
= 0;
647 ide_parser_cache
= false;
648 store_decls_in_saved_state
= false;
649 load_decls_from_saved_state
= false;
651 shallow_class_decl
= false;
652 force_shallow_decl_fanout
= false;
653 force_load_hot_shallow_decls
= false;
654 fetch_remote_old_decls
= false;
655 use_hack_64_naming_table
= false;
656 skip_hierarchy_checks
= false;
657 num_local_workers
= None
;
658 parallel_type_checking_threshold
= 10;
659 defer_class_declaration_threshold
= None
;
660 defer_class_memory_mb_threshold
= None
;
661 prefetch_deferred_files = false;
662 recheck_capture
= RecheckCapture.default;
663 recli_version
= "STABLE";
664 remote_nonce
= Int64.zero
;
665 remote_type_check
= RemoteTypeCheck.default;
666 remote_worker_key
= None
;
667 remote_check_id
= None
;
668 remote_version_specifier_required
= true;
669 remote_version_specifier
= None
;
670 remote_transport_channel
= None
;
671 naming_sqlite_path
= None
;
672 enable_naming_table_fallback
= false;
673 symbolindex_search_provider
= "SqliteIndex";
674 (* the code actually doesn't use this default for ide_symbolindex_search_provider;
675 it defaults to whatever was computed for symbolindex_search_provider. *)
676 ide_symbolindex_search_provider
= "SqliteIndex";
677 symbolindex_quiet
= false;
678 symbolindex_file
= None
;
679 tico_invalidate_files
= false;
680 tico_invalidate_smart
= false;
681 use_direct_decl_parser
= false;
683 profile_type_check_duration_threshold
= 0.05;
685 profile_type_check_memory_threshold_mb
= 100;
686 profile_type_check_twice
= false;
687 profile_decling
= Typing_service_types.DeclingOff
;
688 profile_owner
= None
;
690 go_to_implementation
= true;
691 allow_unstable_features
= false;
692 stream_errors
= false;
693 watchman
= Watchman.default;
694 save_and_upload_naming_table
= false;
695 log_from_client_when_slow_monitor_connections
= false;
696 naming_sqlite_in_hack_64
= false;
697 workload_quantile
= None
;
698 enable_disk_heap
= true;
699 rollout_group
= None
;
700 machine_class
= None
;
705 try Sys.getenv
"HH_LOCALCONF_PATH" with
706 | _
-> BuildOptions.system_config_path
708 Filename.concat
dir "hh.conf"
710 let apply_overrides ~silent ~current_version ~config ~overrides
=
711 (* We'll apply CLI overrides now at the start so that JustKnobs and experiments_config
712 can be informed about them, e.g. "--config rollout_group=foo" will be able
713 to guide the manner in which JustKnobs picks up values. Don't worry though --
714 we'll apply CLI overrides again at the end, so they overwrite any changes
715 brought by JustKnobs and experiments_config. *)
716 let config = Config_file.apply_overrides ~from
:None ~
config ~overrides
in
717 (* Now is the time for JustKnobs (though it's skipped for tests) *)
719 if Sys_utils.is_test_mode
() then
722 ServerLocalConfigKnobs.apply_justknobs_overrides ~silent
config
724 (* Now is the time for experiments_config overrides *)
725 let experiments_enabled =
727 "experiments_config_enabled"
732 let (experiments_meta
, config) =
733 if experiments_enabled then begin
734 Disk.mkdir_p
GlobalConfig.tmp_dir
;
736 string_
"experiments_config_path" ~
default:GlobalConfig.tmp_dir
config
738 let owner = Sys_utils.get_primary_owner
() in
740 Filename.concat
dir (Printf.sprintf
"hh.%s.experiments" owner)
744 "experiments_config_update"
751 (int_
"experiments_config_ttl_seconds" ~
default:86400 config)
753 let source = string_opt
"experiments_config_source" config in
756 match Experiments_config_file.update ~
file ~
source ~
ttl with
758 | Error message
-> message
760 "Updating experimental config not enabled"
762 if Disk.file_exists
file then
763 (* Apply the experiments overrides *)
764 let experiment_overrides = Config_file.parse_local_config
file in
766 Config_file.apply_overrides
767 ~from
:(Option.some_if
(not silent
) "Experiment_overrides")
769 ~overrides
:experiment_overrides
773 ("Experimental config not found on disk", config)
775 ("Experimental config not enabled", config)
777 (* Finally, reapply the CLI overrides, since they should take
778 precedence over the experiments_config and JustKnobs. *)
780 Config_file.apply_overrides
781 ~from
:(Option.some_if
(not silent
) "--config")
785 (experiments_meta
, config)
787 let load_ fn ~silent ~current_version overrides
=
788 let config = Config_file.parse_local_config fn
in
789 let (experiments_config_meta
, config) =
790 apply_overrides ~silent ~current_version ~
config ~overrides
792 if not silent
then begin
793 Printf.eprintf
"** Combined config:\n%!";
794 Config_file.print_to_stderr
config;
795 Printf.eprintf
"\n%!"
799 string_list
"experiments" ~
default:default.experiments config
803 string_list
"log_categories" ~
default:default.log_categories config
807 Hh_logger.Level.of_enum_string
811 ~
default:(Hh_logger.Level.to_enum_string
default.min_log_level)
814 | Some level
-> level
815 | None
-> Hh_logger.Level.Debug
818 let use_saved_state =
821 ~
default:default.use_saved_state
825 let require_saved_state =
827 "require_saved_state"
828 ~
default:default.require_saved_state
832 let attempt_fix_credentials =
834 "attempt_fix_credentials"
835 ~
default:default.attempt_fix_credentials
842 ~
default:default.enable_on_nfs
846 let enable_fuzzy_search =
848 "enable_fuzzy_search"
849 ~
default:default.enable_fuzzy_search
853 let force_remote_type_check =
855 "force_remote_type_check"
856 ~
default:default.force_remote_type_check
863 ~
default:default.lazy_parse
870 ~
default:default.lazy_init
874 let max_purgatory_clients =
875 int_
"max_purgatory_clients" ~
default:default.max_purgatory_clients config
877 let search_chunk_size =
878 int_
"search_chunk_size" ~
default:default.search_chunk_size config
880 let load_state_natively =
882 "load_state_natively_v4"
883 ~
default:default.load_state_natively
887 let load_state_natively_64bit =
889 "load_state_natively_64bit"
890 ~
default:default.load_state_natively_64bit
897 ~
default:default.no_load_64bit
901 let load_state_natively_download_timeout =
903 "load_state_natively_download_timeout"
904 ~
default:default.load_state_natively_download_timeout
907 let load_state_natively_dirty_files_timeout =
909 "load_state_natively_dirty_files_timeout"
910 ~
default:default.load_state_natively_dirty_files_timeout
913 let use_dummy_informant =
915 "use_dummy_informant"
916 ~
default:default.use_dummy_informant
920 let informant_min_distance_restart =
922 "informant_min_distance_restart"
923 ~
default:default.informant_min_distance_restart
926 let type_decl_bucket_size =
927 int_
"type_decl_bucket_size" ~
default:default.type_decl_bucket_size config
929 let extend_fast_bucket_size =
931 "extend_fast_bucket_size"
932 ~
default:default.extend_fast_bucket_size
935 let io_priority = int_
"io_priority" ~
default:default.io_priority config in
936 let cpu_priority = int_
"cpu_priority" ~
default:default.cpu_priority config in
937 let can_skip_deptable =
940 ~
default:default.can_skip_deptable
945 string_list
"shm_dirs" ~
default:default.shm_dirs config
946 |> List.map ~f
:(fun dir -> Path.(to_string
@@ make
dir))
948 let shm_use_sharded_hashtbl =
950 "shm_use_sharded_hashtbl"
951 ~
default:default.shm_use_sharded_hashtbl
955 let shm_enable_eviction =
957 "shm_enable_eviction"
958 ~
default:default.shm_enable_eviction
962 let shm_max_evictable_bytes =
964 "shm_max_evictable_bytes"
965 ~
default:default.shm_max_evictable_bytes
968 let max_workers = int_opt
"max_workers" config in
969 let max_bucket_size =
970 int_
"max_bucket_size" ~
default:default.max_bucket_size config
972 let interrupt_on_watchman =
974 "interrupt_on_watchman"
975 ~
default:default.interrupt_on_watchman
979 let interrupt_on_client =
981 "interrupt_on_client"
982 ~
default:default.interrupt_on_client
986 let use_full_fidelity_parser =
988 "use_full_fidelity_parser"
989 ~
default:default.use_full_fidelity_parser
996 ~
default:default.trace_parsing
1000 let prechecked_files =
1003 ~
default:default.prechecked_files
1007 let enable_type_check_filter_files =
1009 "enable_type_check_filter_files"
1010 ~
default:default.enable_type_check_filter_files
1017 ~
default:default.re_worker
1021 (* ide_serverless CANNOT use bool_if_min_version, since it's needed before we yet know root/version *)
1022 let ide_serverless =
1023 bool_
"ide_serverless" ~
default:default.ide_serverless config
1025 (* ide_ranked_autocomplete CANNOT use bool_if_min_version, since it's needed before we yet know root/version *)
1026 let ide_ranked_autocomplete =
1028 "ide_ranked_autocomplete"
1029 ~
default:default.ide_ranked_autocomplete
1032 (* ide_ffp_autocomplete CANNOT use bool_if_min_version, since it's needed before we yet know root/version *)
1033 let ide_ffp_autocomplete =
1034 bool_
"ide_ffp_autocomplete" ~
default:default.ide_ffp_autocomplete config
1036 let ide_max_num_decls =
1037 int_
"ide_max_num_decls" ~
default:default.ide_max_num_decls config
1039 let ide_max_num_shallow_decls =
1041 "ide_max_num_shallow_decls"
1042 ~
default:default.ide_max_num_shallow_decls
1045 let ide_max_num_linearizations =
1047 "ide_max_num_linearizations"
1048 ~
default:default.ide_max_num_linearizations
1051 let predeclare_ide =
1054 ~
default:default.predeclare_ide
1058 let max_typechecker_worker_memory_mb =
1059 int_opt
"max_typechecker_worker_memory_mb" config
1061 let longlived_workers =
1064 ~
default:default.longlived_workers
1068 let remote_execution =
1071 ~
default:default.remote_execution
1078 ~
default:default.hg_aware
1082 let store_decls_in_saved_state =
1084 "store_decls_in_saved_state"
1085 ~
default:default.store_decls_in_saved_state
1089 let load_decls_from_saved_state =
1091 "load_decls_from_saved_state"
1092 ~
default:default.load_decls_from_saved_state
1096 let hg_aware_parsing_restart_threshold =
1098 "hg_aware_parsing_restart_threshold"
1099 ~
default:default.hg_aware_parsing_restart_threshold
1102 let hg_aware_redecl_restart_threshold =
1104 "hg_aware_redecl_restart_threshold"
1105 ~
default:default.hg_aware_redecl_restart_threshold
1108 let hg_aware_recheck_restart_threshold =
1110 "hg_aware_recheck_restart_threshold"
1111 ~
default:default.hg_aware_recheck_restart_threshold
1114 let ide_parser_cache =
1117 ~
default:default.ide_parser_cache
1122 int_
"idle_gc_slice" ~
default:default.idle_gc_slice config
1124 let shallow_class_decl =
1126 "shallow_class_decl"
1127 ~
default:default.shallow_class_decl
1131 let force_shallow_decl_fanout =
1133 "force_shallow_decl_fanout"
1134 ~
default:default.force_shallow_decl_fanout
1138 let force_load_hot_shallow_decls =
1140 "force_load_hot_shallow_decls"
1141 ~
default:default.force_load_hot_shallow_decls
1145 let fetch_remote_old_decls =
1147 "fetch_remote_old_decls"
1148 ~
default:default.fetch_remote_old_decls
1152 let use_hack_64_naming_table =
1154 "use_hack_64_naming_table"
1155 ~
default:default.use_hack_64_naming_table
1159 let skip_hierarchy_checks =
1161 "skip_hierarchy_checks"
1162 ~
default:default.skip_hierarchy_checks
1166 let parallel_type_checking_threshold =
1168 "parallel_type_checking_threshold"
1169 ~
default:default.parallel_type_checking_threshold
1172 let num_local_workers = int_opt
"num_local_workers" config in
1173 let defer_class_declaration_threshold =
1174 int_opt
"defer_class_declaration_threshold" config
1176 let defer_class_memory_mb_threshold =
1177 int_opt
"defer_class_memory_mb_threshold" config
1179 let prefetch_deferred_files =
1181 "prefetch_deferred_files"
1186 let recheck_capture =
1187 RecheckCapture.load ~current_version ~
default:default.recheck_capture config
1190 match string_opt
"remote_nonce" config with
1191 | Some n
-> Int64.of_string n
1192 | None
-> Int64.zero
1194 let remote_type_check =
1195 RemoteTypeCheck.load
1197 ~
default:default.remote_type_check
1201 Watchman.load ~current_version ~
default:default.watchman config
1204 string_
"recli_version" ~
default:default.recli_version config
1206 let remote_worker_key = string_opt
"remote_worker_key" config in
1207 let remote_check_id = string_opt
"remote_check_id" config in
1208 let remote_version_specifier_required =
1210 "remote_version_specifier_required"
1211 ~
default:default.remote_version_specifier_required
1215 let remote_version_specifier = string_opt
"remote_version_specifier" config in
1216 let remote_transport_channel = string_opt
"remote_transport_channel" config in
1217 let enable_naming_table_fallback =
1219 "enable_naming_table_fallback"
1220 ~
default:default.enable_naming_table_fallback
1224 let naming_sqlite_path =
1225 if enable_naming_table_fallback then
1226 string_opt
"naming_sqlite_path" config
1230 let symbolindex_search_provider =
1232 "symbolindex_search_provider"
1233 ~
default:default.symbolindex_search_provider
1236 let ide_symbolindex_search_provider =
1238 "ide_symbolindex_search_provider"
1239 ~
default:symbolindex_search_provider
1242 let symbolindex_quiet =
1245 ~
default:default.symbolindex_quiet
1249 let symbolindex_file = string_opt
"symbolindex_file" config in
1250 let tico_invalidate_files =
1252 "tico_invalidate_files"
1253 ~
default:default.tico_invalidate_files
1257 let tico_invalidate_smart =
1259 "tico_invalidate_smart"
1260 ~
default:default.tico_invalidate_smart
1264 let use_direct_decl_parser =
1266 "use_direct_decl_parser"
1267 ~
default:default.use_direct_decl_parser
1274 ~
default:default.profile_log
1278 let profile_type_check_duration_threshold =
1280 "profile_type_check_duration_threshold"
1281 ~
default:default.profile_type_check_duration_threshold
1284 let profile_type_check_memory_threshold_mb =
1286 "profile_type_check_memory_threshold_mb"
1287 ~
default:default.profile_type_check_memory_threshold_mb
1290 let profile_type_check_twice =
1292 "profile_type_check_twice"
1293 ~
default:default.profile_type_check_twice
1297 let profile_decling =
1298 match string_
"profile_decling" ~
default:"off" config with
1299 | "off" -> Typing_service_types.DeclingOff
1300 | "top_counts" -> Typing_service_types.DeclingTopCounts
1301 | "all_telemetry" ->
1302 Typing_service_types.DeclingAllTelemetry
{ callstacks
= false }
1303 | "all_telemetry_callstacks" ->
1304 Typing_service_types.DeclingAllTelemetry
{ callstacks
= true }
1307 "profile_decling: off | top_counts | all_telemetry | all_telemetry_callstacks"
1309 let profile_owner = string_opt
"profile_owner" config in
1311 string_
"profile_desc" ~
default:default.profile_desc config
1313 let go_to_implementation =
1315 "go_to_implementation"
1316 ~
default:default.go_to_implementation
1320 let allow_unstable_features =
1322 "allow_unstable_features"
1323 ~
default:default.allow_unstable_features
1330 ~
default:default.stream_errors
1334 let save_and_upload_naming_table =
1336 "save_and_upload_naming_table"
1337 ~
default:default.save_and_upload_naming_table
1341 let log_from_client_when_slow_monitor_connections =
1343 "log_from_client_when_slow_monitor_connections"
1344 ~
default:default.log_from_client_when_slow_monitor_connections
1348 let naming_sqlite_in_hack_64 =
1350 "naming_sqlite_in_hack_64"
1351 ~
default:default.naming_sqlite_in_hack_64
1355 let force_shallow_decl_fanout =
1356 if force_shallow_decl_fanout && not
use_direct_decl_parser then (
1358 "You have force_shallow_decl_fanout=true but use_direct_decl_parser=false. This is incompatible. Turning off force_shallow_decl_fanout";
1361 force_shallow_decl_fanout
1363 let force_load_hot_shallow_decls =
1364 if force_load_hot_shallow_decls && not
force_shallow_decl_fanout then (
1366 "You have force_load_hot_shallow_decls=true but force_shallow_decl_fanout=false. This is incompatible. Turning off force_load_hot_shallow_decls";
1369 force_load_hot_shallow_decls
1371 let fetch_remote_old_decls =
1372 if fetch_remote_old_decls && not
force_shallow_decl_fanout then (
1374 "You have fetch_remote_old_decls=true but force_shallow_decl_fanout=false. This is incompatible. Turning off force_load_hot_shallow_decls";
1377 fetch_remote_old_decls
1379 let workload_quantile =
1380 int_list_opt
"workload_quantile" config >>= fun l
->
1383 if 0 <= m
&& m
<= n
then
1384 Some
{ count
= n
; index
= m
}
1385 else if 0 <= n
&& n
<= m
then
1386 Some
{ count
= m
; index
= n
}
1391 let enable_disk_heap =
1394 ~
default:default.enable_disk_heap
1398 let rollout_group = string_opt
"rollout_group" config in
1399 let machine_class = string_opt
"machine_class" config in
1402 attempt_fix_credentials;
1405 experiments_config_meta
;
1407 require_saved_state;
1408 load_state_natively;
1409 load_state_natively_64bit;
1411 load_state_natively_download_timeout;
1412 load_state_natively_dirty_files_timeout;
1413 max_purgatory_clients;
1414 type_decl_bucket_size;
1415 extend_fast_bucket_size;
1417 enable_fuzzy_search;
1425 shm_use_sharded_hashtbl;
1426 shm_enable_eviction;
1427 shm_max_evictable_bytes;
1430 use_dummy_informant;
1431 informant_min_distance_restart;
1432 use_full_fidelity_parser;
1433 interrupt_on_watchman;
1434 interrupt_on_client;
1437 enable_type_check_filter_files;
1440 ide_ranked_autocomplete;
1441 ide_ffp_autocomplete;
1443 ide_max_num_shallow_decls;
1444 ide_max_num_linearizations;
1445 ide_symbolindex_search_provider;
1447 max_typechecker_worker_memory_mb;
1451 hg_aware_parsing_restart_threshold;
1452 hg_aware_redecl_restart_threshold;
1453 hg_aware_recheck_restart_threshold;
1455 store_decls_in_saved_state;
1456 load_decls_from_saved_state;
1459 force_shallow_decl_fanout;
1460 force_load_hot_shallow_decls;
1461 fetch_remote_old_decls;
1462 use_hack_64_naming_table;
1463 skip_hierarchy_checks;
1465 parallel_type_checking_threshold;
1466 defer_class_declaration_threshold;
1467 defer_class_memory_mb_threshold;
1468 prefetch_deferred_files;
1475 remote_version_specifier_required;
1476 remote_version_specifier;
1477 remote_transport_channel;
1479 enable_naming_table_fallback;
1480 symbolindex_search_provider;
1483 tico_invalidate_files;
1484 tico_invalidate_smart;
1485 use_direct_decl_parser;
1487 profile_type_check_duration_threshold;
1488 profile_type_check_memory_threshold_mb;
1489 profile_type_check_twice;
1493 go_to_implementation;
1494 allow_unstable_features;
1497 force_remote_type_check;
1498 save_and_upload_naming_table;
1499 log_from_client_when_slow_monitor_connections;
1500 naming_sqlite_in_hack_64;
1507 (** Loads the config from [path]. Uses JustKnobs and ExperimentsConfig to override.
1508 On top of that, applies [config_overrides]. If [silent] then prints what it's doing
1510 let load ~silent ~current_version config_overrides
=
1511 load_ path ~silent ~current_version config_overrides
1513 let to_rollout_flags (options
: t
) : HackEventLogger.rollout_flags
=
1516 use_direct_decl_parser = options
.use_direct_decl_parser;
1517 longlived_workers = options
.longlived_workers;
1518 require_saved_state = options
.require_saved_state;
1519 stream_errors = options
.stream_errors;
1520 force_shallow_decl_fanout = options
.force_shallow_decl_fanout;
1521 log_from_client_when_slow_monitor_connections =
1522 options
.log_from_client_when_slow_monitor_connections;
1523 naming_sqlite_in_hack_64 = options
.naming_sqlite_in_hack_64;
1524 use_hack_64_naming_table = options
.use_hack_64_naming_table;
1525 enable_disk_heap = options
.enable_disk_heap;
1526 ide_max_num_decls = options
.ide_max_num_decls;
1527 ide_max_num_shallow_decls = options
.ide_max_num_shallow_decls;
1528 ide_max_num_linearizations = options
.ide_max_num_linearizations;
1529 max_bucket_size = options
.max_bucket_size;
1530 max_workers = Option.value options
.max_workers ~
default:(-1);
1531 max_typechecker_worker_memory_mb =
1532 Option.value options
.max_typechecker_worker_memory_mb ~
default:(-1);