Create RestartScheduler

Summary:
These changes introduce the RestartScheduler which for now is a copy of the FileScheduler:

- added it as a possible argument to the recently added `--scheduler` option.
- made the necessary changes in `InferAnalyze` to call it if it was chosen.

Reviewed By: ngorogiannis

Differential Revision: D19373505

fbshipit-source-id: 98f065057
master
Fernando Gasperi Jabalera 5 years ago committed by Facebook Github Bot
parent 774223165c
commit e6069f3ef7

@ -1690,7 +1690,7 @@ INTERNAL OPTIONS
Reset the list of folders containing linters definitions to be
empty (see linters-def-folder).
--scheduler { File | SyntacticCallGraph }
--scheduler { file | restart | callgraph }
Specify the scheduler used for the analysis phase
--scuba-logging

@ -15,6 +15,7 @@ let make sources =
in
let next x =
let res = gen.next x in
(* see defn of gen above to see why res should never match Some (Procname _) *)
match res with None -> None | Some (Procname _) -> assert false | Some (File _) as v -> v
in
{gen with next}

@ -119,10 +119,12 @@ let schedule sources =
SyntacticCallGraph.make sources )
else
match Config.scheduler with
| SyntacticCallGraph ->
SyntacticCallGraph.make sources
| File ->
FileScheduler.make sources
| Restart ->
RestartScheduler.make sources
| SyntacticCallGraph ->
SyntacticCallGraph.make sources
let analyze source_files_to_analyze =

@ -0,0 +1,22 @@
(*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
open! IStd
(** This behaves exactly the same as the FileScheduler so far. The goal is that it will use a work
queue and proc locking to avoid repeating work and hopefully get some in process cache hits. *)
let make sources =
let gen =
List.rev_map sources ~f:(fun sf -> SchedulerTypes.File sf)
|> List.permute ~random_state:(Random.State.make (Array.create ~len:1 0))
|> ProcessPool.TaskGenerator.of_list
in
let next x =
let res = gen.next x in
(* see defn of gen above to see why res should never match Some (Procname _) *)
match res with None -> None | Some (Procname _) -> assert false | Some (File _) as v -> v
in
{gen with next}

@ -0,0 +1,9 @@
(*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
open! IStd
val make : SourceFile.t list -> SchedulerTypes.target ProcessPool.TaskGenerator.t

@ -92,7 +92,7 @@ type build_system =
| BXcode
[@@deriving compare]
type scheduler = File | SyntacticCallGraph [@@deriving equal]
type scheduler = File | Restart | SyntacticCallGraph [@@deriving equal]
let equal_build_system = [%compare.equal: build_system]
@ -2357,7 +2357,7 @@ and export_changed_functions_output =
and scheduler =
CLOpt.mk_symbol ~long:"scheduler" ~default:File ~eq:equal_scheduler
~symbols:[("File", File); ("SyntacticCallGraph", SyntacticCallGraph)]
~symbols:[("file", File); ("restart", Restart); ("callgraph", SyntacticCallGraph)]
"Specify the scheduler used for the analysis phase"

@ -25,7 +25,7 @@ type build_system =
| BNdk
| BXcode
type scheduler = File | SyntacticCallGraph [@@deriving equal]
type scheduler = File | Restart | SyntacticCallGraph [@@deriving equal]
val equal_build_system : build_system -> build_system -> bool

Loading…
Cancel
Save