From ddfa6fc96ec80c0335893f516cb54d54113d4104 Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Fri, 14 Feb 2020 07:38:38 -0800 Subject: [PATCH] [scheduler][callgraph] use counter instead of set of scheduled procs Summary: No reason to use a set when an integer will suffice. This further reduces GC churn. Reviewed By: fgasperij Differential Revision: D19888300 fbshipit-source-id: 9fc8c73f5 --- infer/src/backend/SyntacticCallGraph.ml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/infer/src/backend/SyntacticCallGraph.ml b/infer/src/backend/SyntacticCallGraph.ml index 8de762317..4a66826f5 100644 --- a/infer/src/backend/SyntacticCallGraph.ml +++ b/infer/src/backend/SyntacticCallGraph.ml @@ -57,9 +57,9 @@ let bottom_up sources : SchedulerTypes.target ProcessPool.TaskGenerator.t = in (* prime the pending queue so that [empty] doesn't immediately return true *) fill_queue () ; - let scheduled = ref Procname.Set.empty in + let scheduled = ref 0 in let is_empty () = - let empty = Queue.is_empty pending && Procname.Set.is_empty !scheduled in + let empty = Int.equal 0 !scheduled && Queue.is_empty pending in if empty then ( remaining := 0 ; L.progress "Finished call graph scheduling, %d procs remaining (in, or reaching, cycles).@." @@ -79,14 +79,14 @@ let bottom_up sources : SchedulerTypes.target ProcessPool.TaskGenerator.t = | Some n when n.flag || not (CallGraph.mem syntactic_call_graph n.id) -> next () | Some n -> - scheduled := Procname.Set.add n.pname !scheduled ; + incr scheduled ; CallGraph.flag syntactic_call_graph n.pname ; Some (Procname n.pname) in let finished ~completed:_ = function | Procname pname -> decr remaining ; - scheduled := Procname.Set.remove pname !scheduled ; + decr scheduled ; CallGraph.remove syntactic_call_graph pname | File _ -> L.die InternalError "Only Procnames are scheduled but File target was received"