Skip to content

Commit 5ea6c07

Browse files
panagosg7meta-codesync[bot]
authored andcommitted
[flow] Add server.max_workers.full_check flowconfig option
Summary: We'll probably want to have lazy servers start with a smaller number of workers, but keep full checks at a higher number. This diff adds a new flowconfig option that overrides the worker count specifically for non-lazy mode (full checks). In lazy mode, the regular server.max_workers (or system default) is used instead. Priority order: CLI --max-workers > server.max_workers.full_check (non-lazy only) > server.max_workers > system default. Reviewed By: SamChou19815 Differential Revision: D95162909 fbshipit-source-id: dfe220f960a880a376796e1314d8fbf017a0d120
1 parent 41b0a28 commit 5ea6c07

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

src/commands/commandUtils.ml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1544,9 +1544,21 @@ let make_options
15441544
opt_max_header_tokens = FlowConfig.max_header_tokens flowconfig;
15451545
opt_max_seconds_for_check_per_worker = FlowConfig.max_seconds_for_check_per_worker flowconfig;
15461546
opt_max_workers =
1547-
Base.Option.first_some options_flags.max_workers (FlowConfig.max_workers flowconfig)
1548-
|> Base.Option.value ~default:Sys_utils.nbr_procs
1549-
|> min Sys_utils.nbr_procs;
1547+
(* Priority: CLI --max-workers > server.max_workers.full_check (non-lazy only)
1548+
> server.max_workers > system default (nbr_procs).
1549+
The result is capped at nbr_procs. *)
1550+
(let config_max_workers =
1551+
if not opt_lazy_mode then
1552+
Base.Option.first_some
1553+
(FlowConfig.max_workers_full_check flowconfig)
1554+
(FlowConfig.max_workers flowconfig)
1555+
else
1556+
FlowConfig.max_workers flowconfig
1557+
in
1558+
Base.Option.first_some options_flags.max_workers config_max_workers
1559+
|> Base.Option.value ~default:Sys_utils.nbr_procs
1560+
|> min Sys_utils.nbr_procs
1561+
);
15501562
opt_merge_timeout;
15511563
opt_missing_module_generators = FlowConfig.missing_module_generators flowconfig;
15521564
opt_module = FlowConfig.module_system flowconfig;

src/commands/config/flowConfig.ml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ module Opts = struct
107107
max_header_tokens: int;
108108
max_seconds_for_check_per_worker: float;
109109
max_workers: int option;
110+
max_workers_full_check: int option;
110111
merge_timeout: int option;
111112
missing_module_generators: (Str.regexp * string) list;
112113
module_declaration_dirnames: string list;
@@ -265,6 +266,7 @@ module Opts = struct
265266
max_header_tokens = 10;
266267
max_seconds_for_check_per_worker = 5.0;
267268
max_workers = None;
269+
max_workers_full_check = None;
268270
merge_timeout = Some 100;
269271
missing_module_generators = [];
270272
module_declaration_dirnames = ["<PROJECT_ROOT>/@flowtyped"];
@@ -1271,6 +1273,9 @@ module Opts = struct
12711273
boolean (fun opts v -> Ok { opts with saved_state_skip_version_check = v })
12721274
);
12731275
("server.max_workers", uint (fun opts v -> Ok { opts with max_workers = Some v }));
1276+
( "server.max_workers.full_check",
1277+
uint (fun opts v -> Ok { opts with max_workers_full_check = Some v })
1278+
);
12741279
( "server.max_workers.windows",
12751280
uint (fun opts v ->
12761281
if Sys.win32 then
@@ -2033,6 +2038,8 @@ let max_seconds_for_check_per_worker c = c.options.Opts.max_seconds_for_check_pe
20332038

20342039
let max_workers c = c.options.Opts.max_workers
20352040

2041+
let max_workers_full_check c = c.options.Opts.max_workers_full_check
2042+
20362043
let merge_timeout c = c.options.Opts.merge_timeout
20372044

20382045
let missing_module_generators c = c.options.Opts.missing_module_generators

src/commands/config/flowConfig.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ val max_seconds_for_check_per_worker : config -> float
194194

195195
val max_workers : config -> int option
196196

197+
val max_workers_full_check : config -> int option
198+
197199
val merge_timeout : config -> int option
198200

199201
val missing_module_generators : config -> (Str.regexp * string) list

0 commit comments

Comments
 (0)