From 3ea69369deed9f8e2c44bbdc72cb2a4d8a7bf0c3 Mon Sep 17 00:00:00 2001 From: Catherine Gasnier Date: Wed, 30 Sep 2020 08:16:20 -0700 Subject: [PATCH] only read counters when profile_log option is set Summary: ... to avoid possibly expensive system calls Differential Revision: D21740519 fbshipit-source-id: 0810f46acd834ef1fc1287bd33f39e8d90f47a03 --- hphp/hack/src/typing/typing_check_service.ml | 46 ++++++++++++++++------------ 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/hphp/hack/src/typing/typing_check_service.ml b/hphp/hack/src/typing/typing_check_service.ml index e06ec8da434..efaa0106a44 100644 --- a/hphp/hack/src/typing/typing_check_service.ml +++ b/hphp/hack/src/typing/typing_check_service.ml @@ -373,28 +373,34 @@ let process_files let (errors, deferred) = match fn with | Check file -> - let start_counters = read_counters () in - let result = process_file dynamic_view_files ctx errors file in - let end_counters = read_counters () in - let second_run_end_counters = - if check_info.profile_type_check_twice then - (* we're running this routine solely for the side effect *) - (* of seeing how long it takes to run. *) - let (_ignored : process_file_results) = - process_file dynamic_view_files ctx errors file + let process_file () = + process_file dynamic_view_files ctx errors file + in + let result = + if check_info.profile_log then ( + let start_counters = read_counters () in + let result = process_file () in + let end_counters = read_counters () in + let second_run_end_counters = + if check_info.profile_type_check_twice then + (* we're running this routine solely for the side effect *) + (* of seeing how long it takes to run. *) + let _ignored = process_file () in + Some (read_counters ()) + else + None in - Some (read_counters ()) - else - None + profile_log + ~check_info + ~start_counters + ~end_counters + ~second_run_end_counters + ~file + ~result; + result + ) else + process_file () in - if check_info.profile_log then - profile_log - ~check_info - ~start_counters - ~end_counters - ~second_run_end_counters - ~file - ~result; (result.errors, result.computation) | Declare path -> let errors = Decl_service.decl_file ctx errors path in -- 2.11.4.GIT