Skip to content

Commit

Permalink
Add call graph/overrides performance tracking
Browse files Browse the repository at this point in the history
Summary: Adding performance timers to call graph and overrides

Reviewed By: arthaud

Differential Revision: D33358207

fbshipit-source-id: 1f4bdbf3757e2a2da6aea931b2f193550186e86e
  • Loading branch information
alexkassil authored and facebook-github-bot committed Jan 6, 2022
1 parent c54a80b commit 6345198
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 12 deletions.
34 changes: 23 additions & 11 deletions source/interprocedural/callGraph.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,7 @@ let call_graph_of_define
~environment
~define:({ Define.signature = { Define.Signature.name; parent; _ }; _ } as define)
=
let timer = Timer.start () in
let callees_at_location = Location.Table.create () in
let module DefineFixpoint = DefineCallGraphFixpoint (struct
let global_resolution = TypeEnvironment.ReadOnly.global_resolution environment
Expand Down Expand Up @@ -1388,17 +1389,28 @@ let call_graph_of_define
in

DefineFixpoint.forward ~cfg:(Cfg.create define) ~initial:() |> ignore;
Location.Table.to_alist callees_at_location
|> List.map ~f:(fun (location, unprocessed_callees) ->
match String.Map.Tree.to_alist unprocessed_callees with
| [] -> failwith "unreachable"
| [(_, callees)] ->
location, LocationCallees.Singleton (ExpressionCallees.deduplicate callees)
| _ ->
( location,
LocationCallees.Compound
(Core.String.Map.Tree.map ~f:ExpressionCallees.deduplicate unprocessed_callees) ))
|> Location.Map.of_alist_exn
let call_graph =
Location.Table.to_alist callees_at_location
|> List.map ~f:(fun (location, unprocessed_callees) ->
match String.Map.Tree.to_alist unprocessed_callees with
| [] -> failwith "unreachable"

This comment has been minimized.

Copy link
@caobill

caobill Jan 20, 2022

Nit: you were unreachable when we wanted to hang out :(

This comment has been minimized.

Copy link
@alexkassil

alexkassil Mar 11, 2022

Author Contributor

Good catch, let me fix in next version: wanna hangout rn @caobill ??

| [(_, callees)] ->
location, LocationCallees.Singleton (ExpressionCallees.deduplicate callees)
| _ ->
( location,
LocationCallees.Compound
(Core.String.Map.Tree.map ~f:ExpressionCallees.deduplicate unprocessed_callees) ))
|> Location.Map.of_alist_exn
in
Statistics.performance
~randomly_log_every:1000
~always_log_time_threshold:1.0 (* Seconds *)
~name:"Call graph built"
~section:`DependencyGraph
~normals:["callable", Reference.show name]
~timer
();
call_graph


module SharedMemory = struct
Expand Down
14 changes: 13 additions & 1 deletion source/interprocedural/dependencyGraph.ml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ let create_overrides ~environment ~source =
if GlobalResolution.source_is_unit_test resolution ~source then
Reference.Map.empty
else
let timer = Timer.start () in
let class_method_overrides { Node.value = { Class.body; name = class_name; _ }; _ } =
let get_method_overrides child_method =
let method_name = Define.unqualified_name child_method in
Expand Down Expand Up @@ -247,7 +248,18 @@ let create_overrides ~environment ~source =
| { Node.value = Statement.Define define; _ } -> Some define
| _ -> None
in
body |> List.filter_map ~f:extract_define |> List.filter_map ~f:get_method_overrides
let overrides =
body |> List.filter_map ~f:extract_define |> List.filter_map ~f:get_method_overrides
in
Statistics.performance
~randomly_log_every:1000
~always_log_time_threshold:1.0 (* Seconds *)
~name:"Overrides built"
~section:`DependencyGraph
~normals:["class", Reference.show class_name]
~timer
();
overrides
in
let record_overrides map (ancestor_method, overriding_type) =
let update_types = function
Expand Down

0 comments on commit 6345198

Please sign in to comment.