diff --git a/infer/src/backend/Differential.ml b/infer/src/backend/Differential.ml index 8006020a2..bf9f1db1a 100644 --- a/infer/src/backend/Differential.ml +++ b/infer/src/backend/Differential.ml @@ -152,7 +152,7 @@ let issue_of_cost cost_info ~delta ~prev_cost ~curr_cost = if CostDomain.BasicCost.is_top curr_cost then IssueType.infinite_execution_time_call else if CostDomain.BasicCost.is_zero curr_cost then IssueType.zero_execution_time_call else if ExternalPerfData.in_profiler_data_map procname then - IssueType.performance_variation_critical_cold_start + IssueType.time_complexity_increase_cold_start else IssueType.performance_variation in let curr_degree_with_term = CostDomain.BasicCost.get_degree_with_term curr_cost in @@ -174,14 +174,20 @@ let issue_of_cost cost_info ~delta ~prev_cost ~curr_cost = if Config.developer_mode then curr_cost_msg fmt () else Format.fprintf fmt "Please make sure this is an expected change." in + let cold_start_msg = + if ExternalPerfData.in_profiler_data_map procname then + "This function is called during cold start. It is very important to avoid potential \ + regressions in this phase." + else "" + in let prev_degree_with_term = CostDomain.BasicCost.get_degree_with_term prev_cost in - Format.asprintf "Complexity of this function has %a from %a to %a. %a" + Format.asprintf "Complexity of this function has %a from %a to %a. %s %a" (MarkupFormatter.wrap_bold pp_delta) delta (MarkupFormatter.wrap_monospaced (CostDomain.BasicCost.pp_degree ~only_bigO:true)) prev_degree_with_term (MarkupFormatter.wrap_monospaced (CostDomain.BasicCost.pp_degree ~only_bigO:true)) - curr_degree_with_term pp_extra_msg () + curr_degree_with_term cold_start_msg pp_extra_msg () in let line = cost_info.Jsonbug_t.loc.lnum in let column = cost_info.Jsonbug_t.loc.cnum in diff --git a/infer/src/base/IssueType.ml b/infer/src/base/IssueType.ml index 1f32e2f5c..f26ced994 100644 --- a/infer/src/base/IssueType.ml +++ b/infer/src/base/IssueType.ml @@ -347,8 +347,6 @@ let parameter_not_null_checked = from_string "PARAMETER_NOT_NULL_CHECKED" let performance_variation = from_string "PERFORMANCE_VARIATION" -let performance_variation_critical_cold_start = from_string "PERFORMANCE_VARIATION_COLD_START" - let pointer_size_mismatch = from_string "POINTER_SIZE_MISMATCH" let precondition_not_found = from_string "PRECONDITION_NOT_FOUND" @@ -403,6 +401,8 @@ let tainted_memory_allocation = from_string "TAINTED_MEMORY_ALLOCATION" let thread_safety_violation = from_string "THREAD_SAFETY_VIOLATION" +let time_complexity_increase_cold_start = from_string "TIME_COMPLEXITY_INCREASE_COLD_START" + let unary_minus_applied_to_unsigned_expression = from_string ~enabled:false "UNARY_MINUS_APPLIED_TO_UNSIGNED_EXPRESSION" diff --git a/infer/src/base/IssueType.mli b/infer/src/base/IssueType.mli index 43661fa6a..cb61cc447 100644 --- a/infer/src/base/IssueType.mli +++ b/infer/src/base/IssueType.mli @@ -245,8 +245,6 @@ val parameter_not_null_checked : t val performance_variation : t -val performance_variation_critical_cold_start : t - val pointer_size_mismatch : t val precondition_not_found : t @@ -299,6 +297,8 @@ val tainted_memory_allocation : t val thread_safety_violation : t +val time_complexity_increase_cold_start : t + val unary_minus_applied_to_unsigned_expression : t val uninitialized_value : t diff --git a/infer/tests/build_systems/differential_of_costs_report/fixed.exp b/infer/tests/build_systems/differential_of_costs_report/fixed.exp index b544aafc9..1eabb448c 100644 --- a/infer/tests/build_systems/differential_of_costs_report/fixed.exp +++ b/infer/tests/build_systems/differential_of_costs_report/fixed.exp @@ -1,2 +1,2 @@ PERFORMANCE_VARIATION, no_bucket, src/DiffExample.java, DiffExample.f6(java.util.ArrayList):void, 0, [Updated Cost is 5 + list.length × log(list.length) (degree is 1 + 1⋅log),{list.length},call to void DiffExample.f5(ArrayList),Modeled call to List.length,{list.length},call to void DiffExample.f5(ArrayList),Modeled call to List.length] -PERFORMANCE_VARIATION_COLD_START, no_bucket, src/DiffExampleColdStart.java, DiffExampleColdStart.f6(java.util.ArrayList):void, 0, [Updated Cost is 5 + list.length × log(list.length) (degree is 1 + 1⋅log),{list.length},call to void DiffExampleColdStart.f5(ArrayList),Modeled call to List.length,{list.length},call to void DiffExampleColdStart.f5(ArrayList),Modeled call to List.length] +TIME_COMPLEXITY_INCREASE_COLD_START, no_bucket, src/DiffExampleColdStart.java, DiffExampleColdStart.f6(java.util.ArrayList):void, 0, [Updated Cost is 5 + list.length × log(list.length) (degree is 1 + 1⋅log),{list.length},call to void DiffExampleColdStart.f5(ArrayList),Modeled call to List.length,{list.length},call to void DiffExampleColdStart.f5(ArrayList),Modeled call to List.length] diff --git a/infer/tests/build_systems/differential_of_costs_report/introduced.exp b/infer/tests/build_systems/differential_of_costs_report/introduced.exp index 7e149c40b..45459b710 100644 --- a/infer/tests/build_systems/differential_of_costs_report/introduced.exp +++ b/infer/tests/build_systems/differential_of_costs_report/introduced.exp @@ -2,5 +2,5 @@ INFINITE_EXECUTION_TIME_CALL, no_bucket, src/DiffExample.java, DiffExample.f1(in PERFORMANCE_VARIATION, no_bucket, src/DiffExample.java, DiffExample.f4(int):int, 0, [Updated Cost is 6 + 5 ⋅ k (degree is 1),{k},Loop at line 45] PERFORMANCE_VARIATION, no_bucket, src/DiffExample.java, DiffExample.f5(java.util.ArrayList):void, 0, [Updated Cost is 2 + list.length × log(list.length) (degree is 1 + 1⋅log),{list.length},Modeled call to List.length,{list.length},Modeled call to List.length] INFINITE_EXECUTION_TIME_CALL, no_bucket, src/DiffExampleColdStart.java, DiffExampleColdStart.f1(int):void, 0, [Unbounded loop,Loop at line 26] -PERFORMANCE_VARIATION_COLD_START, no_bucket, src/DiffExampleColdStart.java, DiffExampleColdStart.f4(int):int, 0, [Updated Cost is 6 + 5 ⋅ k (degree is 1),{k},Loop at line 45] +TIME_COMPLEXITY_INCREASE_COLD_START, no_bucket, src/DiffExampleColdStart.java, DiffExampleColdStart.f4(int):int, 0, [Updated Cost is 6 + 5 ⋅ k (degree is 1),{k},Loop at line 45] PERFORMANCE_VARIATION, no_bucket, src/DiffExampleColdStart.java, DiffExampleColdStart.f5(java.util.ArrayList):void, 0, [Updated Cost is 2 + list.length × log(list.length) (degree is 1 + 1⋅log),{list.length},Modeled call to List.length,{list.length},Modeled call to List.length]