From fda0871030b1f8cb908028fcac31f68006c81c8c Mon Sep 17 00:00:00 2001 From: Varun Arora Date: Wed, 28 Mar 2018 05:23:22 -0700 Subject: [PATCH] [reporting] fix reporting of total_frontend and total_backend stats Reviewed By: dulmarod Differential Revision: D7417086 fbshipit-source-id: f4ac596 --- infer/src/infer.ml | 8 +------- infer/src/integration/Diff.ml | 8 -------- infer/src/integration/Driver.ml | 18 +++++++++++------- infer/src/integration/Driver.mli | 2 -- 4 files changed, 12 insertions(+), 24 deletions(-) diff --git a/infer/src/infer.ml b/infer/src/infer.ml index 474615c34..1b0b61e81 100644 --- a/infer/src/infer.ml +++ b/infer/src/infer.ml @@ -20,12 +20,8 @@ let run driver_mode = let open Driver in run_prologue driver_mode ; let changed_files = read_config_changed_files () in - register_perf_stats_report PerfStats.TotalFrontend ; capture driver_mode ~changed_files ; - PerfStats.get_reporter PerfStats.TotalFrontend () ; - register_perf_stats_report PerfStats.TotalBackend ; analyze_and_report driver_mode ~changed_files ; - PerfStats.get_reporter PerfStats.TotalBackend () ; run_epilogue driver_mode @@ -132,9 +128,7 @@ let () = F.fprintf fmt "of cluster %s" (Filename.basename cluster) in L.environment_info "Starting analysis %a" pp_cluster_opt Config.cluster_cmdline ; - Driver.register_perf_stats_report PerfStats.TotalBackend ; - Driver.analyze_and_report Analyze ~changed_files:(Driver.read_config_changed_files ()) ; - PerfStats.get_reporter PerfStats.TotalBackend () + Driver.analyze_and_report Analyze ~changed_files:(Driver.read_config_changed_files ()) | Report -> InferPrint.main ~report_json:None | ReportDiff -> diff --git a/infer/src/integration/Diff.ml b/infer/src/integration/Diff.ml index 106836ab5..2411ec0db 100644 --- a/infer/src/integration/Diff.ml +++ b/infer/src/integration/Diff.ml @@ -63,12 +63,8 @@ let gen_previous_driver_mode script = let diff driver_mode = Driver.run_prologue driver_mode ; let changed_files = Driver.read_config_changed_files () in - Driver.register_perf_stats_report PerfStats.TotalFrontend ; Driver.capture driver_mode ~changed_files ; - PerfStats.get_reporter PerfStats.TotalFrontend () ; - Driver.register_perf_stats_report PerfStats.TotalBackend ; Driver.analyze_and_report ~suppress_console_report:true driver_mode ~changed_files ; - PerfStats.get_reporter PerfStats.TotalBackend () ; let current_report = Some (save_report Current) in (* Some files in the current checkout may be deleted in the old checkout. If we kept the results of the previous capture and analysis around, we would report issues on these files again in the previous checkout, which is wrong. Do not do anything too smart for now and just delete all results from the analysis of the current checkout. *) ResultsDir.delete_capture_and_analysis_data () ; @@ -79,12 +75,8 @@ let diff driver_mode = Option.value_map ~default:driver_mode ~f:gen_previous_driver_mode Config.gen_previous_build_command_script in - Driver.register_perf_stats_report PerfStats.TotalFrontend ; Driver.capture previous_driver_mode ~changed_files ; - PerfStats.get_reporter PerfStats.TotalFrontend () ; - Driver.register_perf_stats_report PerfStats.TotalBackend ; Driver.analyze_and_report ~suppress_console_report:true previous_driver_mode ~changed_files ; - PerfStats.get_reporter PerfStats.TotalBackend () ; checkout Current ; let previous_report = Some (save_report Previous) in (* compute differential *) diff --git a/infer/src/integration/Driver.ml b/infer/src/integration/Driver.ml index 8936c29ff..7059253fe 100644 --- a/infer/src/integration/Driver.ml +++ b/infer/src/integration/Driver.ml @@ -62,6 +62,11 @@ let clean_compilation_command mode = None +let register_perf_stats_report stats_type = + let rtime_span, initial_times = (Mtime_clock.counter (), Unix.times ()) in + PerfStats.register_report (PerfStats.Time (rtime_span, initial_times)) stats_type + + (* Clean up the results dir to select only what's relevant to go in the Buck cache. In particular, get rid of non-deterministic outputs.*) let clean_results_dir () = @@ -208,6 +213,7 @@ let capture ~changed_files mode = (* pretend prog is the root directory of the project *) PythonMain.go args | PythonCapture (build_system, build_cmd) -> + register_perf_stats_report PerfStats.TotalFrontend ; L.progress "Capturing in %s mode...@." (Config.string_of_build_system build_system) ; let in_buck_mode = Config.equal_build_system build_system BBuck in let infer_py = Config.lib_dir ^/ "python" ^/ "infer.py" in @@ -282,7 +288,8 @@ let capture ~changed_files mode = Config.print_usage_exit () | status -> command_error_handling ~always_die:true ~prog:infer_py ~args status) - () + () ; + PerfStats.get_reporter PerfStats.TotalFrontend () | XcodeXcpretty (prog, args) -> L.progress "Capturing using xcodebuild and xcpretty...@." ; check_xcpretty () ; @@ -312,9 +319,11 @@ let run_parallel_analysis ~changed_files : unit = let execute_analyze ~changed_files = + register_perf_stats_report PerfStats.TotalBackend ; if Int.equal Config.jobs 1 || Config.cluster_cmdline <> None then InferAnalyze.main ~changed_files ~makefile:"" - else run_parallel_analysis ~changed_files + else run_parallel_analysis ~changed_files ; + PerfStats.get_reporter PerfStats.TotalBackend () let report ?(suppress_console= false) () = @@ -528,11 +537,6 @@ let mode_from_command_line = mode_of_build_command (List.rev Config.rest) ) -let register_perf_stats_report stats_type = - let rtime_span, initial_times = (Mtime_clock.counter (), Unix.times ()) in - PerfStats.register_report (PerfStats.Time (rtime_span, initial_times)) stats_type - - let run_prologue mode = if CLOpt.is_originator then ( L.environment_info "%a@\n" Config.pp_version () ; diff --git a/infer/src/integration/Driver.mli b/infer/src/integration/Driver.mli index 354b0b0ff..91b29b05c 100644 --- a/infer/src/integration/Driver.mli +++ b/infer/src/integration/Driver.mli @@ -34,8 +34,6 @@ val mode_from_command_line : mode Lazy.t val mode_of_build_command : string list -> mode (** driver mode computed from the build command alone, eg [["buck"; "build"; ...]] gives [PythonCapture (BBuck, ["buck"; "build"; ...])] *) -val register_perf_stats_report : PerfStats.stats_type -> unit - val run_prologue : mode -> unit (** prepare the environment for running the given mode *)