[logging] Always log PerfStats to EventLogger

Summary:
- PerformanceStats rows will be logged to EventLogger regardless of whether Infer is in developer mode
- PerformanceStats files will still not be created unless Infer is in developer mode

Reviewed By: dulmarod

Differential Revision: D7169403

fbshipit-source-id: 85bd7de
master
Varun Arora 7 years ago committed by Facebook Github Bot
parent 37720e1bbf
commit 5d6951a545

@ -977,7 +977,7 @@ let main ~report_json =
; (Stats, init_stats_format_list ())
; (Summary, []) ]
in
if Config.developer_mode then register_perf_stats_report () ;
register_perf_stats_report () ;
init_files formats_by_report_kind ;
match Config.from_json_report with
| Some fname ->

@ -166,16 +166,18 @@ let report_at_exit file source_file stats_type () =
let stats, stats_event = stats source_file stats_type in
let json_stats = to_json stats in
EventLogger.log stats_event ;
try
Unix.mkdir_p (Filename.dirname file) ;
(* the same report may be registered across different infer processes *)
Utils.write_file_with_locking file ~f:(fun stats_oc ->
Yojson.Basic.pretty_to_channel stats_oc json_stats )
with exc ->
L.internal_error "Info: failed to write stats to %s@\n%s@\n%s@\n%s@." file
(Exn.to_string exc)
(Yojson.Basic.pretty_to_string json_stats)
(Printexc.get_backtrace ())
(* We always log to EventLogger, but json files are unnecessary to log outside of developer mode *)
if Config.developer_mode then
try
Unix.mkdir_p (Filename.dirname file) ;
(* the same report may be registered across different infer processes *)
Utils.write_file_with_locking file ~f:(fun stats_oc ->
Yojson.Basic.pretty_to_channel stats_oc json_stats )
with exc ->
L.internal_error "Info: failed to write stats to %s@\n%s@\n%s@\n%s@." file
(Exn.to_string exc)
(Yojson.Basic.pretty_to_string json_stats)
(Printexc.get_backtrace ())
with exc ->
L.internal_error "Info: failed to compute stats for %s@\n%s@\n%s@." file (Exn.to_string exc)
(Printexc.get_backtrace ())

@ -128,7 +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 ;
if Config.developer_mode then InferAnalyze.register_perf_stats_report () ;
InferAnalyze.register_perf_stats_report () ;
Driver.analyze_and_report Analyze ~changed_files:(Driver.read_config_changed_files ())
| Report ->
InferPrint.main ~report_json:None

@ -32,8 +32,8 @@ let register_perf_stats_report source_file =
let init_global_state_for_capture_and_linters source_file =
L.(debug Capture Medium) "Processing %s" (Filename.basename (SourceFile.to_abs_path source_file)) ;
if Config.developer_mode then register_perf_stats_report source_file ;
Language.curr_language := Language.Clang ;
register_perf_stats_report source_file ;
if Config.capture then DB.Results_dir.init source_file ;
CFrontend_config.reset_global_state ()

@ -542,7 +542,7 @@ let run_prologue mode =
anyway, pretend that we are not called from another make to prevent make falling back to a
mono-threaded execution. *)
Unix.unsetenv "MAKEFLAGS" ;
if Config.developer_mode then register_perf_stats_report () ;
register_perf_stats_report () ;
()

@ -21,8 +21,8 @@ let register_perf_stats_report source_file =
let init_global_state source_file =
if Config.developer_mode then register_perf_stats_report source_file ;
Language.curr_language := Language.Java ;
register_perf_stats_report source_file ;
DB.Results_dir.init source_file ;
Ident.NameGenerator.reset () ;
JContext.reset_exn_node_table ()

Loading…
Cancel
Save