[cost] Revise suppressing cost reports

Summary:
It suppresses cost reports of access methods, anonymous class methods, and auto-generated methods.
For those methods, this diff blocks reporting both expensive
issue (`EXPENSIVE_COLD_START/_UI_THREAD`) and complexity increase issue (`COMPLEXITY_INCREASE`).

Reviewed By: jvillard

Differential Revision: D21303068

fbshipit-source-id: 1c9533956
master
Sungkeun Cho 5 years ago committed by Facebook GitHub Bot
parent f207b3dfda
commit a61965d622

@ -235,6 +235,12 @@ module WorstCaseCost = struct
exec_partition tenv initial extras instr_cfg_wto
end
let is_report_suppressed pname =
Procname.is_java_access_method pname
|| Procname.is_java_anonymous_inner_class_method pname
|| Procname.is_java_autogen_method pname
module Check = struct
let report_threshold pname summary ~name ~location ~cost CostIssues.{expensive_issue} ~threshold
~is_on_ui_thread =
@ -283,11 +289,7 @@ module Check = struct
let check_and_report ~is_on_ui_thread WorstCaseCost.{costs; reports} proc_desc summary =
let pname = Procdesc.get_proc_name proc_desc in
let proc_loc = Procdesc.get_loc proc_desc in
if
(not (Procname.is_java_access_method pname))
&& (not (Procname.is_java_anonymous_inner_class_method pname))
&& not (Procname.is_java_autogen_method pname)
then (
if not (is_report_suppressed pname) then (
CostIssues.CostKindMap.iter2 CostIssues.enabled_cost_map reports
~f:(fun _kind (CostIssues.{name; threshold} as kind_spec) -> function
| ThresholdReports.Threshold _ | ThresholdReports.NoReport ->

@ -20,3 +20,5 @@ val instantiate_cost :
-> callee_cost:CostDomain.BasicCost.t
-> loc:Location.t
-> CostDomain.BasicCost.t
val is_report_suppressed : Procname.t -> bool

@ -289,10 +289,10 @@ let collect_issues summary issues_acc =
let write_costs summary (outfile : Utils.outfile) =
JsonCostsPrinter.pp outfile.fmt
{ loc= Summary.get_loc summary
; proc_name= Summary.get_proc_name summary
; cost_opt= summary.Summary.payloads.Payloads.cost }
let proc_name = Summary.get_proc_name summary in
if not (Cost.is_report_suppressed proc_name) then
JsonCostsPrinter.pp outfile.fmt
{loc= Summary.get_loc summary; proc_name; cost_opt= summary.Summary.payloads.Payloads.cost}
(** Process lint issues of a procedure *)

@ -1 +1 @@
{"top":{"current":4,"previous":2},"zero":{"current":0,"previous":0},"degrees":[{"degree":0,"current":10,"previous":9},{"degree":100,"current":3,"previous":5},{"degree":101,"current":4,"previous":0},{"degree":200,"current":2,"previous":4}]}
{"top":{"current":4,"previous":2},"zero":{"current":0,"previous":0},"degrees":[{"degree":0,"current":9,"previous":7},{"degree":100,"current":3,"previous":5},{"degree":101,"current":4,"previous":0},{"degree":200,"current":1,"previous":4}]}

@ -1,4 +1,3 @@
EXECUTION_TIME_COMPLEXITY_INCREASE, no_bucket, src/DiffExample.java, DiffExample$1.toString():java.lang.String, 0, [Updated Cost of toString is 16 + 13 ⋅ this.this$0.z + 5 ⋅ this.this$0.z × this.this$0.z (degree is 2),{this.this$0.z},call to void DiffExample.f8(int),call to int DiffExample.f4(int),Loop at line 57,{this.this$0.z},call to void DiffExample.f8(int),Loop at line 79]
INFINITE_EXECUTION_TIME, no_bucket, src/DiffExample.java, DiffExample.f1(int):void, 0, [Unbounded loop,Loop at line 38]
EXECUTION_TIME_COMPLEXITY_INCREASE, no_bucket, src/DiffExample.java, DiffExample.f4(int):int, 0, [Updated Cost of f4 is 6 + 5 ⋅ k (degree is 1),{k},Loop at line 57]
EXECUTION_TIME_COMPLEXITY_INCREASE, no_bucket, src/DiffExample.java, DiffExample.f5(java.util.ArrayList):void, 0, [Updated Cost of f5 is 2 + list.length × log(list.length) (degree is 1 + 1⋅log),{list.length},Modeled call to Collections.sort,{list.length},Modeled call to Collections.sort]

Loading…
Cancel
Save