From 06f5eee6809ea586f1986d94a84da177ed2d5e51 Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Fri, 21 Aug 2020 09:31:49 -0700 Subject: [PATCH] [merge] measure tenv size only in debug mode Summary: `Obj.reachable_words` can be very slow on large values, so only call it in debug mode. Also, measure the time we spend for compressing/storing the global type environment. Reviewed By: jvillard Differential Revision: D23264532 fbshipit-source-id: 4a9456ab7 --- infer/src/IR/Tenv.ml | 10 ++++++---- infer/src/backend/mergeCapture.ml | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/infer/src/IR/Tenv.ml b/infer/src/IR/Tenv.ml index 2434b2a35..1a08de65d 100644 --- a/infer/src/IR/Tenv.ml +++ b/infer/src/IR/Tenv.ml @@ -174,11 +174,13 @@ let store_to_filename tenv tenv_filename = let store_global tenv = (* update in-memory global tenv for later uses by this process, e.g. in single-core mode the frontend and backend run in the same process *) - L.debug Capture Quiet "Tenv.store: global tenv has size %d bytes.@." - (Obj.(reachable_words (repr tenv)) * (Sys.word_size / 8)) ; + if Config.debug_level_capture > 0 then + L.debug Capture Quiet "Tenv.store: global tenv has size %d bytes.@." + (Obj.(reachable_words (repr tenv)) * (Sys.word_size / 8)) ; let tenv = TypenameHashNormalizer.normalize tenv in - L.debug Capture Quiet "Tenv.store: canonicalized tenv has size %d bytes.@." - (Obj.(reachable_words (repr tenv)) * (Sys.word_size / 8)) ; + if Config.debug_level_capture > 0 then + L.debug Capture Quiet "Tenv.store: canonicalized tenv has size %d bytes.@." + (Obj.(reachable_words (repr tenv)) * (Sys.word_size / 8)) ; global_tenv := Some tenv ; store_to_filename tenv global_tenv_path diff --git a/infer/src/backend/mergeCapture.ml b/infer/src/backend/mergeCapture.ml index 9ce6b26df..88b0bfbad 100644 --- a/infer/src/backend/mergeCapture.ml +++ b/infer/src/backend/mergeCapture.ml @@ -23,8 +23,10 @@ let merge_global_tenvs infer_deps_file = Tenv.read global_tenv_path |> Option.iter ~f:(fun tenv -> Tenv.merge ~src:tenv ~dst:global_tenv) in Utils.iter_infer_deps ~project_root:Config.project_root ~f:merge infer_deps_file ; + let time1 = Mtime_clock.counter () in Tenv.store_global global_tenv ; - L.progress "Merging type environments took %a@." Mtime.Span.pp (Mtime_clock.count time0) + L.progress "Merging type environments took %a, of which %a were spent storing the global tenv@." + Mtime.Span.pp (Mtime_clock.count time0) Mtime.Span.pp (Mtime_clock.count time1) let merge_json_results infer_out_src json_entry =