Skip to content

Commit aa4b895

Browse files
authored
output: time: Add quick profiling data on scanning time (#391)
Required-by PR semgrep/semgrep-proprietary/pull/4164
1 parent 9e30c82 commit aa4b895

7 files changed

+8511
-5896
lines changed

semgrep_output_v1.atd

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,14 @@ type profile = {
10161016
<python repr="dict">
10171017
<ts repr="map">;
10181018

1019+
(* EXPERIMENTAL *)
10191020
?parsing_time : parsing_time option;
1021+
(* EXPERIMENTAL *)
1022+
?scanning_time : scanning_time option;
1023+
(* EXPERIMENTAL *)
1024+
?matching_time : matching_time option;
1025+
(* EXPERIMENTAL *)
1026+
?tainting_time : tainting_time option;
10201027

10211028
targets: target_times list;
10221029
total_bytes: int;
@@ -1025,22 +1032,78 @@ type profile = {
10251032
?max_memory_bytes : int option;
10261033
}
10271034

1035+
(* EXPERIMENTAL *)
10281036
type file_time <ocaml attr="deriving show"> = {
10291037
fpath: fpath;
10301038
ftime: float;
10311039
}
10321040

1041+
(* EXPERIMENTAL *)
1042+
type file_rule_time <ocaml attr="deriving show"> = {
1043+
fpath: fpath;
1044+
rule_id: rule_id;
1045+
time: float;
1046+
}
1047+
1048+
(* EXPERIMENTAL *)
1049+
type def_rule_time <ocaml attr="deriving show"> = {
1050+
fpath: fpath;
1051+
fline : int;
1052+
rule_id: rule_id;
1053+
time: float;
1054+
}
1055+
1056+
(* EXPERIMENTAL *)
10331057
type summary_stats = {
10341058
mean: float;
10351059
std_dev: float;
10361060
}
10371061

1062+
(* These ratios are numbers in [0, 1], and we would hope that both 'time_ratio'
1063+
and 'count_ratio' are very close to 0. In bad cases, we may see the 'count_ratio'
1064+
being close to 0 while the 'time_ratio' is above 0.5, meaning that a small number
1065+
of very slow files/etc represent a large amount of the total processing time. *)
1066+
(* EXPERIMENTAL *)
1067+
type very_slow_stats = {
1068+
time_ratio: float;
1069+
(* Ratio "sum of very slow time" / "total time" *)
1070+
count_ratio: float;
1071+
(* Ratio "very slow count" / "total count" *)
1072+
}
1073+
1074+
(* EXPERIMENTAL *)
10381075
type parsing_time = {
10391076
total_time: float;
10401077
per_file_time: summary_stats;
1078+
?very_slow_stats: very_slow_stats option;
10411079
very_slow_files: file_time list; (* ascending order *)
10421080
}
10431081

1082+
(* Scanning time (includes matching and tainting) *)
1083+
(* EXPERIMENTAL *)
1084+
type scanning_time = {
1085+
total_time : float;
1086+
per_file_time: summary_stats;
1087+
very_slow_stats: very_slow_stats;
1088+
very_slow_files: file_time list; (* ascending order *)
1089+
}
1090+
1091+
(* EXPERIMENTAL *)
1092+
type matching_time = {
1093+
total_time : float;
1094+
per_file_and_rule_time : summary_stats;
1095+
very_slow_stats: very_slow_stats;
1096+
very_slow_rules_on_files: file_rule_time list; (* ascending order *)
1097+
}
1098+
1099+
(* EXPERIMENTAL *)
1100+
type tainting_time = {
1101+
total_time : float;
1102+
per_def_and_rule_time : summary_stats;
1103+
very_slow_stats: very_slow_stats;
1104+
very_slow_rules_on_defs: def_rule_time list; (* ascending order *)
1105+
}
1106+
10441107
type target_times = {
10451108
path: fpath;
10461109
num_bytes: int;

semgrep_output_v1.jsonschema

Lines changed: 78 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

semgrep_output_v1.proto

Lines changed: 44 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)