From ad40152a6771fcd4b3b1b6a3796e19f6fbe0cd19 Mon Sep 17 00:00:00 2001 From: Lucian Wischik Date: Wed, 19 Jan 2022 09:51:02 -0800 Subject: [PATCH] odstatus in ProfileTypeCheck.process_file Reviewed By: CatherineGasnier Differential Revision: D33587949 fbshipit-source-id: 1a35d01464bb75b6726f88c084bce859a9253318 --- hphp/hack/src/server/serverLocalConfig.ml | 7 +--- hphp/hack/src/stubs/logging/hackEventLogger.ml | 36 +++++++++------- hphp/hack/src/typing/typing_check_service.ml | 58 +++++++++++++------------- 3 files changed, 53 insertions(+), 48 deletions(-) diff --git a/hphp/hack/src/server/serverLocalConfig.ml b/hphp/hack/src/server/serverLocalConfig.ml index be9c4e88794..9159e4c916a 100644 --- a/hphp/hack/src/server/serverLocalConfig.ml +++ b/hphp/hack/src/server/serverLocalConfig.ml @@ -1278,12 +1278,7 @@ let load_ fn ~silent ~current_version overrides = "profile_decling: off | top_counts | all_telemetry | all_telemetry_callstacks" in let profile_owner = string_opt "profile_owner" config in - let profile_desc = - string_ - "profile_desc" - ~default:HackEventLogger.PerFileProfilingConfig.(default.profile_desc) - config - in + let profile_desc = string_opt "profile_desc" config in let profile_slow_threshold = float_ "profile_slow_threshold" diff --git a/hphp/hack/src/stubs/logging/hackEventLogger.ml b/hphp/hack/src/stubs/logging/hackEventLogger.ml index 4aca7e2f1b5..d88e1e92338 100644 --- a/hphp/hack/src/stubs/logging/hackEventLogger.ml +++ b/hphp/hack/src/stubs/logging/hackEventLogger.ml @@ -20,7 +20,7 @@ module PerFileProfilingConfig = struct profile_type_check_twice: bool; profile_decling: profile_decling; profile_owner: string option; - profile_desc: string; + profile_desc: string option; profile_slow_threshold: float; } @@ -32,7 +32,7 @@ module PerFileProfilingConfig = struct profile_type_check_twice = false; profile_decling = DeclingOff; profile_owner = None; - profile_desc = ""; + profile_desc = None; profile_slow_threshold = 0.; } end @@ -493,17 +493,9 @@ let worker_exception _ = () module ProfileTypeCheck = struct type stats = unit - type batch_info = { - init_id: string; - check_reason: string; - recheck_id: string option; - worker_id: string; - batch_number: int; - batch_size: int; - start_hh_stats: stats; - start_typecheck_stats: stats; - start_batch_stats: stats; - } + type batch_info = unit + + type typecheck_info = unit let get_stats ~include_current_process:_ @@ -512,8 +504,24 @@ module ProfileTypeCheck = struct _ = () + let get_typecheck_info + ~init_id:_ + ~check_reason:_ + ~recheck_id:_ + ~start_hh_stats:_ + ~start_typecheck_stats:_ + ~config:_ = + () + + let get_batch_info + ~typecheck_info:_ + ~worker_id:_ + ~batch_number:_ + ~batch_size:_ + ~start_batch_stats:_ = + () + let process_file - ~config:_ ~batch_info:_ ~file_index:_ ~file:_ diff --git a/hphp/hack/src/typing/typing_check_service.ml b/hphp/hack/src/typing/typing_check_service.ml index 90b99776278..bbe1aa160f8 100644 --- a/hphp/hack/src/typing/typing_check_service.ml +++ b/hphp/hack/src/typing/typing_check_service.ml @@ -427,7 +427,6 @@ let process_one_file if Option.is_none remote_execution then HackEventLogger.ProfileTypeCheck.process_file - ~config:check_info.per_file_profiling ~batch_info ~file_index:(ProcessFilesTally.count tally) ~file:(Option.map file ~f:(fun file -> file.path)) @@ -460,26 +459,22 @@ let process_files ~(check_info : check_info) ~(worker_id : string) ~(batch_number : int) - ~(start_typecheck_stats : HackEventLogger.ProfileTypeCheck.stats) : + ~(typecheck_info : HackEventLogger.ProfileTypeCheck.typecheck_info) : typing_result * computation_progress = Decl_counters.set_mode check_info.per_file_profiling .HackEventLogger.PerFileProfilingConfig.profile_decling; let _prev_counters_state = Counters.reset () in let batch_info = - { - HackEventLogger.ProfileTypeCheck.init_id = check_info.init_id; - check_reason = check_info.check_reason; - recheck_id = check_info.recheck_id; - worker_id; - batch_number; - batch_size = List.length progress.remaining; - start_hh_stats = CgroupProfiler.get_initial_stats (); - start_typecheck_stats; - start_batch_stats = - get_stats ~include_slightly_costly_stats:true ProcessFilesTally.empty; - } + HackEventLogger.ProfileTypeCheck.get_batch_info + ~typecheck_info + ~worker_id + ~batch_number + ~batch_size:(List.length progress.remaining) + ~start_batch_stats: + (get_stats ~include_slightly_costly_stats:true ProcessFilesTally.empty) in + if not longlived_workers then SharedMem.invalidate_local_caches (); File_provider.local_changes_push_sharedmem_stack (); Ast_provider.local_changes_push_sharedmem_stack (); @@ -553,7 +548,7 @@ let load_and_process_files ~(check_info : check_info) ~(worker_id : string) ~(batch_number : int) - ~(start_typecheck_stats : HackEventLogger.ProfileTypeCheck.stats) : + ~(typecheck_info : HackEventLogger.ProfileTypeCheck.typecheck_info) : typing_result * computation_progress = Option.iter check_info.memtrace_dir ~f:(fun temp_dir -> let file = Caml.Filename.temp_file ~temp_dir "memtrace.worker." ".ctf" in @@ -573,7 +568,7 @@ let load_and_process_files ~check_info ~worker_id ~batch_number - ~start_typecheck_stats + ~typecheck_info (*****************************************************************************) (* Let's go! That's where the action is *) @@ -861,7 +856,7 @@ let process_in_parallel ~(longlived_workers : bool) ~(remote_execution : ReEnv.t option) ~(check_info : check_info) - ~(start_typecheck_stats : HackEventLogger.ProfileTypeCheck.stats) : + ~(typecheck_info : HackEventLogger.ProfileTypeCheck.typecheck_info) : typing_result * Delegate.state * Telemetry.t @@ -915,7 +910,7 @@ let process_in_parallel ~longlived_workers ~remote_execution ~check_info - ~start_typecheck_stats + ~typecheck_info ~worker_id ~batch_number: (SMap.find_opt worker_id !batch_counts_by_worker_id @@ -980,7 +975,7 @@ let process_sequentially ~longlived_workers ~remote_execution ~check_info - ~start_typecheck_stats : + ~typecheck_info : typing_result * (Diagnostic_pusher.t option * seconds_since_epoch option) = let progress = { completed = []; remaining = BigList.as_list fnl; deferred = [] } @@ -998,7 +993,7 @@ let process_sequentially ~check_info ~worker_id:"master" ~batch_number:(-1) - ~start_typecheck_stats + ~typecheck_info in let push_result = possibly_push_new_errors_to_lsp_client @@ -1090,12 +1085,19 @@ let go_with_interrupt ~(longlived_workers : bool) ~(remote_execution : ReEnv.t option) ~(check_info : check_info) : (_ * result) job_result = - let start_typecheck_stats = - HackEventLogger.ProfileTypeCheck.get_stats - ~include_current_process:false - ~include_slightly_costly_stats:true - ~shmem_heap_size:(SharedMem.SMTelemetry.heap_size ()) - (Telemetry.create ()) + let typecheck_info = + HackEventLogger.ProfileTypeCheck.get_typecheck_info + ~init_id:check_info.init_id + ~check_reason:check_info.check_reason + ~recheck_id:check_info.recheck_id + ~start_hh_stats:(CgroupProfiler.get_initial_stats ()) + ~start_typecheck_stats: + (HackEventLogger.ProfileTypeCheck.get_stats + ~include_current_process:false + ~include_slightly_costly_stats:true + ~shmem_heap_size:(SharedMem.SMTelemetry.heap_size ()) + (Telemetry.create ())) + ~config:check_info.per_file_profiling in let opts = Provider_context.get_tcopt ctx in let sample_rate = GlobalOptions.tco_typecheck_sample_rate opts in @@ -1140,7 +1142,7 @@ let go_with_interrupt ~longlived_workers ~remote_execution ~check_info - ~start_typecheck_stats + ~typecheck_info in ( typing_result, delegate_state, @@ -1176,7 +1178,7 @@ let go_with_interrupt ~longlived_workers ~remote_execution ~check_info - ~start_typecheck_stats + ~typecheck_info end in let { errors; dep_edges; telemetry = typing_telemetry; adhoc_profiling } = -- 2.11.4.GIT