Skip to content

Commit 430ddbe

Browse files
jvillardfacebook-github-bot
authored andcommitted
[ondemand] pop active procedures one by one
Summary: If we are doing thing right this should be equivalent. Also, before we were clearing the queue over and over for each active procedure until we reached the top. Reviewed By: ngorogiannis Differential Revision: D63633894 fbshipit-source-id: e0352de056a722ca0d05da9fdcef6107f7e285ff
1 parent 5197611 commit 430ddbe

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

infer/src/backend/ondemand.ml

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ module ActiveProcedures : sig
3434

3535
val remove : active -> unit
3636

37-
val clear : unit -> unit
38-
3937
val get_all : unit -> active list
4038
end = struct
4139
type active = SpecializedProcname.t
@@ -44,13 +42,27 @@ end = struct
4442

4543
let currently_analyzed = AnalysisTargets.create ()
4644

45+
let pp_actives fmt =
46+
AnalysisTargets.iteri currently_analyzed ~f:(fun ~key:target ~data:_ ->
47+
F.fprintf fmt "%a,@," SpecializedProcname.pp target )
48+
49+
4750
let mem analysis_target = AnalysisTargets.mem currently_analyzed analysis_target
4851

49-
let add analysis_target = AnalysisTargets.enqueue_back_exn currently_analyzed analysis_target ()
52+
let add analysis_target =
53+
if Config.trace_ondemand then L.progress "add %a@." SpecializedProcname.pp analysis_target ;
54+
AnalysisTargets.enqueue_back_exn currently_analyzed analysis_target ()
55+
5056

51-
let remove analysis_target = AnalysisTargets.remove_exn currently_analyzed analysis_target
57+
let remove analysis_target =
58+
if Config.trace_ondemand then L.progress "remove %a@." SpecializedProcname.pp analysis_target ;
59+
let popped_target, () = AnalysisTargets.dequeue_back_with_key_exn currently_analyzed in
60+
if not (SpecializedProcname.equal popped_target analysis_target) then
61+
L.die InternalError
62+
"Queue structure for ondemand violated: expected to pop %a but got %a instead@\n\
63+
Active procedures: %t@\n"
64+
SpecializedProcname.pp analysis_target SpecializedProcname.pp popped_target pp_actives
5265

53-
let clear () = AnalysisTargets.clear currently_analyzed
5466

5567
let get_all () = AnalysisTargets.keys currently_analyzed
5668
end
@@ -243,7 +255,8 @@ let run_proc_analysis exe_env tenv analysis_req specialization_context ?caller_p
243255
match exn with
244256
| RestartSchedulerException.ProcnameAlreadyLocked _
245257
| MissingDependencyException.MissingDependencyException ->
246-
ActiveProcedures.clear () ;
258+
decr nesting ;
259+
ActiveProcedures.remove {proc_name= callee_pname; specialization} ;
247260
true
248261
| exn ->
249262
if not !logged_error then (

0 commit comments

Comments
 (0)