diff --git a/Android.bp b/Android.bp index b820aef8fc..a7bda8855d 100644 --- a/Android.bp +++ b/Android.bp @@ -13599,19 +13599,7 @@ genrule { "src/trace_processor/perfetto_sql/stdlib/android/winscope/windowmanager.sql", "src/trace_processor/perfetto_sql/stdlib/callstacks/stack_profile.sql", "src/trace_processor/perfetto_sql/stdlib/chrome/**/*.sql", - "src/trace_processor/perfetto_sql/stdlib/common/args.sql", - "src/trace_processor/perfetto_sql/stdlib/common/counters.sql", - "src/trace_processor/perfetto_sql/stdlib/common/metadata.sql", - "src/trace_processor/perfetto_sql/stdlib/common/percentiles.sql", - "src/trace_processor/perfetto_sql/stdlib/common/slices.sql", - "src/trace_processor/perfetto_sql/stdlib/common/timestamps.sql", "src/trace_processor/perfetto_sql/stdlib/counters/intervals.sql", - "src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/args.sql", - "src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/counters.sql", - "src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/metadata.sql", - "src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/percentiles.sql", - "src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/slices.sql", - "src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/timestamps.sql", "src/trace_processor/perfetto_sql/stdlib/export/to_firefox_profile.sql", "src/trace_processor/perfetto_sql/stdlib/graphs/critical_path.sql", "src/trace_processor/perfetto_sql/stdlib/graphs/dominator_tree.sql", diff --git a/BUILD b/BUILD index a23b86c738..ca9ec70545 100644 --- a/BUILD +++ b/BUILD @@ -2974,19 +2974,6 @@ perfetto_filegroup( srcs = glob(["src/trace_processor/perfetto_sql/stdlib/chrome/**/*.sql"]), ) -# GN target: //src/trace_processor/perfetto_sql/stdlib/common:common -perfetto_filegroup( - name = "src_trace_processor_perfetto_sql_stdlib_common_common", - srcs = [ - "src/trace_processor/perfetto_sql/stdlib/common/args.sql", - "src/trace_processor/perfetto_sql/stdlib/common/counters.sql", - "src/trace_processor/perfetto_sql/stdlib/common/metadata.sql", - "src/trace_processor/perfetto_sql/stdlib/common/percentiles.sql", - "src/trace_processor/perfetto_sql/stdlib/common/slices.sql", - "src/trace_processor/perfetto_sql/stdlib/common/timestamps.sql", - ], -) - # GN target: //src/trace_processor/perfetto_sql/stdlib/counters:counters perfetto_filegroup( name = "src_trace_processor_perfetto_sql_stdlib_counters_counters", @@ -2995,19 +2982,6 @@ perfetto_filegroup( ], ) -# GN target: //src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common:common -perfetto_filegroup( - name = "src_trace_processor_perfetto_sql_stdlib_deprecated_v42_common_common", - srcs = [ - "src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/args.sql", - "src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/counters.sql", - "src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/metadata.sql", - "src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/percentiles.sql", - "src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/slices.sql", - "src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/timestamps.sql", - ], -) - # GN target: //src/trace_processor/perfetto_sql/stdlib/export:export perfetto_filegroup( name = "src_trace_processor_perfetto_sql_stdlib_export_export", @@ -3242,9 +3216,7 @@ perfetto_cc_amalgamated_sql( ":src_trace_processor_perfetto_sql_stdlib_android_winscope_winscope", ":src_trace_processor_perfetto_sql_stdlib_callstacks_callstacks", ":src_trace_processor_perfetto_sql_stdlib_chrome_chrome_sql", - ":src_trace_processor_perfetto_sql_stdlib_common_common", ":src_trace_processor_perfetto_sql_stdlib_counters_counters", - ":src_trace_processor_perfetto_sql_stdlib_deprecated_v42_common_common", ":src_trace_processor_perfetto_sql_stdlib_export_export", ":src_trace_processor_perfetto_sql_stdlib_graphs_graphs", ":src_trace_processor_perfetto_sql_stdlib_intervals_intervals", diff --git a/CHANGELOG b/CHANGELOG index 60f31dc7a5..2a33ef5030 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -24,6 +24,10 @@ Unreleased: inserted directly into it. * Removed the `uid_track` table. It was redundant as no data was inserted directly into it. + * Removed `common` package. It has been deprecated since `v42` and most + functionality has been moved into other packages. Notably, the time + conversion functions can be found in `time.conversion` module, and + `thread_slice` is available with `slices.with_context`. Trace Processor: * UI: diff --git a/src/trace_processor/metrics/sql/chrome/chrome_scroll_inputs_per_frame.sql b/src/trace_processor/metrics/sql/chrome/chrome_scroll_inputs_per_frame.sql index 94d279406e..62d84afb28 100644 --- a/src/trace_processor/metrics/sql/chrome/chrome_scroll_inputs_per_frame.sql +++ b/src/trace_processor/metrics/sql/chrome/chrome_scroll_inputs_per_frame.sql @@ -21,7 +21,22 @@ -- The numbers mentioned above are estimates in the ideal case scenario. INCLUDE PERFETTO MODULE chrome.scroll_jank.utils; -INCLUDE PERFETTO MODULE common.slices; + +-- Checks if slice has a descendant with provided name. +CREATE OR REPLACE PERFETTO FUNCTION _has_descendant_slice_with_name( + -- Id of the slice to check descendants of. + id INT, + -- Name of potential descendant slice. + descendant_name STRING +) +-- Whether `descendant_name` is a name of an descendant slice. +RETURNS BOOL AS +SELECT EXISTS( + SELECT 1 + FROM descendant_slice($id) + WHERE name = $descendant_name + LIMIT 1 +); -- Grab all GestureScrollUpdate slices. DROP VIEW IF EXISTS chrome_all_scroll_updates; @@ -29,7 +44,7 @@ CREATE PERFETTO VIEW chrome_all_scroll_updates AS SELECT S.id, chrome_get_most_recent_scroll_begin_id(ts) AS scroll_id, - has_descendant_slice_with_name(S.id, "SubmitCompositorFrameToPresentationCompositorFrame") + _has_descendant_slice_with_name(S.id, "SubmitCompositorFrameToPresentationCompositorFrame") AS is_presented, ts, dur, diff --git a/src/trace_processor/metrics/sql/common/parent_slice.sql b/src/trace_processor/metrics/sql/common/parent_slice.sql index d5c6f242d2..5478d93131 100644 --- a/src/trace_processor/metrics/sql/common/parent_slice.sql +++ b/src/trace_processor/metrics/sql/common/parent_slice.sql @@ -13,5 +13,3 @@ -- See the License for the specific language governing permissions and -- limitations under the License. -- - -INCLUDE PERFETTO MODULE deprecated.v42.common.slices; diff --git a/src/trace_processor/perfetto_sql/engine/perfetto_sql_engine.cc b/src/trace_processor/perfetto_sql/engine/perfetto_sql_engine.cc index 21216b6ced..36bd391784 100644 --- a/src/trace_processor/perfetto_sql/engine/perfetto_sql_engine.cc +++ b/src/trace_processor/perfetto_sql/engine/perfetto_sql_engine.cc @@ -704,8 +704,18 @@ base::Status PerfettoSqlEngine::ExecuteInclude( } std::string package_name = sql_modules::GetPackageName(key); + auto* package = FindPackage(package_name); if (!package) { + if (package_name == "common") { + return base::ErrStatus( + "INCLUDE: Package `common` has been removed and most of the " + "functionality has been moved to other packages. Check " + "`slices.with_context` for replacement for `common.slices` and " + "`time.conversion` for replacement for `common.timestamps`. The " + "documentation for Perfetto standard library can be found at " + "https://perfetto.dev/docs/analysis/stdlib-docs."); + } return base::ErrStatus("INCLUDE: Package '%s' not found", key.c_str()); } return IncludePackageImpl(*package, key, parser); diff --git a/src/trace_processor/perfetto_sql/stdlib/BUILD.gn b/src/trace_processor/perfetto_sql/stdlib/BUILD.gn index bf51d9e116..adaeb73995 100644 --- a/src/trace_processor/perfetto_sql/stdlib/BUILD.gn +++ b/src/trace_processor/perfetto_sql/stdlib/BUILD.gn @@ -22,9 +22,7 @@ perfetto_amalgamated_sql_header("stdlib") { "android", "callstacks", "chrome:chrome_sql", - "common", "counters", - "deprecated/v42/common", "export", "graphs", "intervals", diff --git a/src/trace_processor/perfetto_sql/stdlib/chrome/event_latency.sql b/src/trace_processor/perfetto_sql/stdlib/chrome/event_latency.sql index 62b1d8884c..0d704db2ce 100644 --- a/src/trace_processor/perfetto_sql/stdlib/chrome/event_latency.sql +++ b/src/trace_processor/perfetto_sql/stdlib/chrome/event_latency.sql @@ -2,8 +2,6 @@ -- Use of this source code is governed by a BSD-style license that can be -- found in the LICENSE file. -INCLUDE PERFETTO MODULE deprecated.v42.common.slices; - -- Finds the start timestamp for a given slice's descendant with a given name. -- If there are multiple descendants with a given name, the function will return -- the first one, so it's most useful when working with a timeline broken down @@ -42,6 +40,22 @@ FROM descendant_slice($parent_id) s WHERE s.name GLOB $child_name LIMIT 1; +-- Checks if slice has a descendant with provided name. +CREATE PERFETTO FUNCTION _has_descendant_slice_with_name( + -- Id of the slice to check descendants of. + id INT, + -- Name of potential descendant slice. + descendant_name STRING +) +-- Whether `descendant_name` is a name of an descendant slice. +RETURNS BOOL AS +SELECT EXISTS( + SELECT 1 + FROM descendant_slice($id) + WHERE name = $descendant_name + LIMIT 1 +); + -- Returns the presentation timestamp for a given EventLatency slice. -- This is either the end of -- SwapEndToPresentationCompositorFrame (if it exists), @@ -101,7 +115,7 @@ SELECT slice.ts, slice.dur, EXTRACT_arg(arg_set_id, 'event_latency.event_latency_id') AS scroll_update_id, - has_descendant_slice_with_name( + _has_descendant_slice_with_name( slice.id, 'SubmitCompositorFrameToPresentationCompositorFrame') AS is_presented, @@ -142,7 +156,7 @@ WHERE ( event_type GLOB '*GESTURE_SCROLL*' -- Pinches are only relevant if the frame was presented. OR (event_type GLOB '*GESTURE_PINCH_UPDATE' - AND has_descendant_slice_with_name( + AND _has_descendant_slice_with_name( id, 'SubmitCompositorFrameToPresentationCompositorFrame') ) diff --git a/src/trace_processor/perfetto_sql/stdlib/chrome/graphics_pipeline.sql b/src/trace_processor/perfetto_sql/stdlib/chrome/graphics_pipeline.sql index 909619c501..eae5bd50a2 100644 --- a/src/trace_processor/perfetto_sql/stdlib/chrome/graphics_pipeline.sql +++ b/src/trace_processor/perfetto_sql/stdlib/chrome/graphics_pipeline.sql @@ -2,7 +2,7 @@ -- Use of this source code is governed by a BSD-style license that can be -- found in the LICENSE file. -INCLUDE PERFETTO MODULE deprecated.v42.common.slices; +INCLUDE PERFETTO MODULE slices.with_context; -- `Graphics.Pipeline` steps corresponding to work done by a Viz client to -- produce a frame (i.e. before surface aggregation). Covers steps: diff --git a/src/trace_processor/perfetto_sql/stdlib/common/BUILD.gn b/src/trace_processor/perfetto_sql/stdlib/common/BUILD.gn deleted file mode 100644 index 73db0a7878..0000000000 --- a/src/trace_processor/perfetto_sql/stdlib/common/BUILD.gn +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (C) 2022 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("../../../../../gn/perfetto_sql.gni") - -perfetto_sql_source_set("common") { - sources = [ - "args.sql", - "counters.sql", - "metadata.sql", - "percentiles.sql", - "slices.sql", - "timestamps.sql", - ] -} diff --git a/src/trace_processor/perfetto_sql/stdlib/common/OWNERS b/src/trace_processor/perfetto_sql/stdlib/common/OWNERS deleted file mode 100644 index 0a16b3f250..0000000000 --- a/src/trace_processor/perfetto_sql/stdlib/common/OWNERS +++ /dev/null @@ -1,8 +0,0 @@ -set noparent - -# Please prefer sending to one of the following people -mayzner@google.com -lalitm@google.com - -# For emergency reviews -primiano@google.com diff --git a/src/trace_processor/perfetto_sql/stdlib/common/args.sql b/src/trace_processor/perfetto_sql/stdlib/common/args.sql deleted file mode 100644 index 3d1e793dea..0000000000 --- a/src/trace_processor/perfetto_sql/stdlib/common/args.sql +++ /dev/null @@ -1,20 +0,0 @@ --- --- Copyright 2023 The Android Open Source Project --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- https://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. - --- No new changes allowed. Will be removed after v45 of Perfetto. --- --- We decided to move away from the generalised `common` module and migrate the --- most useful functionality into specialised modules. -INCLUDE PERFETTO MODULE deprecated.v42.common.args; \ No newline at end of file diff --git a/src/trace_processor/perfetto_sql/stdlib/common/counters.sql b/src/trace_processor/perfetto_sql/stdlib/common/counters.sql deleted file mode 100644 index f0c1ce62b1..0000000000 --- a/src/trace_processor/perfetto_sql/stdlib/common/counters.sql +++ /dev/null @@ -1,21 +0,0 @@ --- --- Copyright 2023 The Android Open Source Project --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- https://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. - --- No new changes allowed. Will be removed after v45 of Perfetto. --- --- We decided to move away from the generalised `common` module and migrate the --- most useful functionality into specialised modules. -INCLUDE PERFETTO MODULE deprecated.v42.common.args; -INCLUDE PERFETTO MODULE deprecated.v42.common.counters; \ No newline at end of file diff --git a/src/trace_processor/perfetto_sql/stdlib/common/metadata.sql b/src/trace_processor/perfetto_sql/stdlib/common/metadata.sql deleted file mode 100644 index bd1a0fda32..0000000000 --- a/src/trace_processor/perfetto_sql/stdlib/common/metadata.sql +++ /dev/null @@ -1,21 +0,0 @@ --- --- Copyright 2022 The Android Open Source Project --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- https://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. - --- No new changes allowed. Will be removed after v45 of Perfetto. --- --- We decided to move away from the generalised `common` module and migrate the --- most useful functionality into specialised modules. -INCLUDE PERFETTO MODULE deprecated.v42.common.args; -INCLUDE PERFETTO MODULE deprecated.v42.common.metadata; \ No newline at end of file diff --git a/src/trace_processor/perfetto_sql/stdlib/common/percentiles.sql b/src/trace_processor/perfetto_sql/stdlib/common/percentiles.sql deleted file mode 100644 index 525c95c93f..0000000000 --- a/src/trace_processor/perfetto_sql/stdlib/common/percentiles.sql +++ /dev/null @@ -1,21 +0,0 @@ --- --- Copyright 2023 The Android Open Source Project --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- https://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. - --- No new changes allowed. Will be removed after v45 of Perfetto. --- --- We decided to move away from the generalised `common` module and migrate the --- most useful functionality into specialised modules. -INCLUDE PERFETTO MODULE deprecated.v42.common.args; -INCLUDE PERFETTO MODULE deprecated.v42.common.percentiles; \ No newline at end of file diff --git a/src/trace_processor/perfetto_sql/stdlib/common/slices.sql b/src/trace_processor/perfetto_sql/stdlib/common/slices.sql deleted file mode 100644 index d5d70c9af0..0000000000 --- a/src/trace_processor/perfetto_sql/stdlib/common/slices.sql +++ /dev/null @@ -1,21 +0,0 @@ --- --- Copyright 2022 The Android Open Source Project --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- https://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. - --- No new changes allowed. Will be removed after v45 of Perfetto. --- --- We decided to move away from the generalised `common` module and migrate the --- most useful functionality into specialised modules. -INCLUDE PERFETTO MODULE deprecated.v42.common.args; -INCLUDE PERFETTO MODULE deprecated.v42.common.slices; \ No newline at end of file diff --git a/src/trace_processor/perfetto_sql/stdlib/common/timestamps.sql b/src/trace_processor/perfetto_sql/stdlib/common/timestamps.sql deleted file mode 100644 index 8f91d3b69f..0000000000 --- a/src/trace_processor/perfetto_sql/stdlib/common/timestamps.sql +++ /dev/null @@ -1,21 +0,0 @@ --- --- Copyright 2022 The Android Open Source Project --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- https://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. - --- No new changes allowed. Will be removed after v45 of Perfetto. --- --- We decided to move away from the generalised `common` module and migrate the --- most useful functionality into specialised modules. -INCLUDE PERFETTO MODULE deprecated.v42.common.args; -INCLUDE PERFETTO MODULE deprecated.v42.common.timestamps; \ No newline at end of file diff --git a/src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/BUILD.gn b/src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/BUILD.gn deleted file mode 100644 index a99b51bf83..0000000000 --- a/src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/BUILD.gn +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (C) 2022 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("../../../../../../../gn/perfetto_sql.gni") - -perfetto_sql_source_set("common") { - sources = [ - "args.sql", - "counters.sql", - "metadata.sql", - "percentiles.sql", - "slices.sql", - "timestamps.sql", - ] -} diff --git a/src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/args.sql b/src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/args.sql deleted file mode 100644 index df0615a7d0..0000000000 --- a/src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/args.sql +++ /dev/null @@ -1,31 +0,0 @@ --- --- Copyright 2023 The Android Open Source Project --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- https://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. - --- Returns the formatted value of a given argument. --- Similar to EXTRACT_ARG, but instead of returning the raw value, it returns --- the value formatted according to the 'value_type' column (e.g. for booleans, --- EXTRACT_ARG will return 0 or 1, while FORMATTED_ARG will return 'true' or --- 'false'). -CREATE PERFETTO FUNCTION formatted_arg( - -- Id of the arg set. - arg_set_id INT, - -- Key of the argument. - arg_key STRING -) --- Formatted value of the argument. -RETURNS STRING AS -SELECT display_value -FROM args -WHERE arg_set_id = $arg_set_id AND key = $arg_key; \ No newline at end of file diff --git a/src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/counters.sql b/src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/counters.sql deleted file mode 100644 index 7923c52ebf..0000000000 --- a/src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/counters.sql +++ /dev/null @@ -1,101 +0,0 @@ --- --- Copyright 2023 The Android Open Source Project --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- https://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. - -INCLUDE PERFETTO MODULE deprecated.v42.common.timestamps; - --- Timestamp of first counter value in a counter. -CREATE PERFETTO FUNCTION earliest_timestamp_for_counter_track( - -- Id of a counter track with a counter. - counter_track_id INT) --- Timestamp of first counter value. Null if doesn't exist. -RETURNS LONG AS -SELECT MIN(ts) FROM counter WHERE counter.track_id = $counter_track_id; - --- Counter values with details of counter track with calculated duration of each counter value. --- Duration is calculated as time from counter to the next counter. -CREATE PERFETTO FUNCTION counter_with_dur_for_track( - -- Id of track counter track. - counter_track_id INT) -RETURNS TABLE( - -- Timestamp of the counter value. - ts LONG, - -- Duration of the counter value. - dur LONG, - -- Counter value. - value DOUBLE, - -- Id of the counter track. - track_id INT, - -- Name of the counter track. - track_name STRING, - -- Counter track set id. - track_arg_set_id INT, - -- Counter arg set id. - arg_set_id INT -) AS -SELECT - ts, - LEAD(ts, 1, trace_end()) OVER(ORDER BY ts) - ts AS dur, - value, - track.id AS track_id, - track.name AS track_name, - track.source_arg_set_id AS track_arg_set_id, - counter.arg_set_id AS arg_set_id -FROM counter -JOIN counter_track track ON track.id = counter.track_id -WHERE track.id = $counter_track_id; - --- COUNTER_WITH_DUR_FOR_TRACK but in a specified time. --- Does calculation over the table ends - creates an artificial counter value at --- the start if needed and chops the duration of the last timestamps in range. -CREATE PERFETTO FUNCTION counter_for_time_range( - -- Id of track counter track. - counter_track_id INT, - -- Timestamp of the timerange start. - -- Can be earlier than the first counter value. - start_ts LONG, - -- Timestamp of the timerange end. - end_ts LONG) -RETURNS TABLE( - -- Timestamp of the counter value. - ts LONG, - -- Duration of the counter value. - dur LONG, - -- Counter value. - value DOUBLE, - -- If of the counter track. - track_id INT, - -- Name of the counter track. - track_name STRING, - -- Counter track set id. - track_arg_set_id INT, - -- Counter arg set id. - arg_set_id INT -) AS -SELECT - IIF(ts < $start_ts, $start_ts, ts) AS ts, - IIF( - ts < $start_ts, - dur - ($start_ts - ts), - IIF(ts + dur > $end_ts, $end_ts - ts, dur)) AS dur, - value, - track_id, - track_name, - track_arg_set_id, - arg_set_id -FROM counter_with_dur_for_track($counter_track_id) -WHERE TRUE - AND ts + dur >= $start_ts - AND ts < $end_ts -ORDER BY ts ASC; diff --git a/src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/metadata.sql b/src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/metadata.sql deleted file mode 100644 index e6674779be..0000000000 --- a/src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/metadata.sql +++ /dev/null @@ -1,22 +0,0 @@ --- --- Copyright 2022 The Android Open Source Project --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- https://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. - --- Extracts an int value with the given name from the metadata table. -CREATE PERFETTO FUNCTION extract_int_metadata( - -- The name of the metadata entry. - name STRING) --- int_value for the given name. NULL if there's no such entry. -RETURNS LONG AS -SELECT int_value FROM metadata WHERE name = ($name); \ No newline at end of file diff --git a/src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/percentiles.sql b/src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/percentiles.sql deleted file mode 100644 index e807a78247..0000000000 --- a/src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/percentiles.sql +++ /dev/null @@ -1,169 +0,0 @@ --- --- Copyright 2023 The Android Open Source Project --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- https://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. - -INCLUDE PERFETTO MODULE deprecated.v42.common.counters; -INCLUDE PERFETTO MODULE deprecated.v42.common.timestamps; - -CREATE PERFETTO FUNCTION _number_generator(upper_limit INT) -RETURNS TABLE(num INT) AS -WITH nums AS - (SELECT 1 num UNION SELECT num + 1 - from NUMS - WHERE num < $upper_limit) -SELECT num FROM nums; - -CREATE PERFETTO FUNCTION _earliest_timestamp_for_counter_track( - -- Id of a counter track with a counter. - counter_track_id INT) --- Timestamp of first counter value. Null if doesn't exist. -RETURNS LONG AS -SELECT MIN(ts) FROM counter WHERE counter.track_id = $counter_track_id; - --- COUNTER_WITH_DUR_FOR_TRACK but in a specified time. --- Does calculation over the table ends - creates an artificial counter value at --- the start if needed and chops the duration of the last timestamps in range. -CREATE PERFETTO FUNCTION _counter_for_time_range( - -- Id of track counter track. - counter_track_id INT, - -- Timestamp of the timerange start. - -- Can be earlier than the first counter value. - start_ts LONG, - -- Timestamp of the timerange end. - end_ts LONG) -RETURNS TABLE( - -- Timestamp of the counter value. - ts LONG, - -- Duration of the counter value. - dur LONG, - -- Counter value. - value DOUBLE, - -- If of the counter track. - track_id INT, - -- Name of the counter track. - track_name STRING, - -- Counter track set id. - track_arg_set_id INT, - -- Counter arg set id. - arg_set_id INT -) AS -SELECT - IIF(ts < $start_ts, $start_ts, ts) AS ts, - IIF( - ts < $start_ts, - dur - ($start_ts - ts), - IIF(ts + dur > $end_ts, $end_ts - ts, dur)) AS dur, - value, - track_id, - track_name, - track_arg_set_id, - arg_set_id -FROM counter_with_dur_for_track($counter_track_id) -WHERE TRUE - AND ts + dur >= $start_ts - AND ts < $end_ts -ORDER BY ts ASC; - --- --- Get durations for percentile --- - --- All percentiles (range 1-100) for counter track ID in a given time range. --- --- Percentiles are calculated by: --- 1. Dividing the sum of duration in time range for each value in the counter --- by duration of the counter in range. This gives us `percentile_for)value` (DOUBLE). --- 2. Fetching each percentile by taking floor of each `percentile_for_value`, grouping by --- resulting `percentile` and MIN from value for each grouping. As we are rounding down, --- taking MIN assures most reliable data. --- 3. Filling the possible gaps in percentiles by getting the minimal value from higher --- percentiles for each gap. -CREATE PERFETTO FUNCTION counter_percentiles_for_time_range( - -- Id of the counter track. - counter_track_id INT, - -- Timestamp of start of time range. - start_ts LONG, - -- Timestamp of end of time range. - end_ts LONG) -RETURNS TABLE( - -- All of the numbers from 1 to 100. - percentile INT, - -- Value for the percentile. - value DOUBLE -) AS -WITH percentiles_for_value AS ( - SELECT - value, - (CAST(SUM(dur) OVER(ORDER BY value ASC) AS DOUBLE) / - ($end_ts - MAX($start_ts, _earliest_timestamp_for_counter_track($counter_track_id)))) * 100 - AS percentile_for_value - FROM _COUNTER_FOR_TIME_RANGE($counter_track_id, $start_ts, $end_ts) - ORDER BY value ASC -), -with_gaps AS ( - SELECT - CAST(percentile_for_value AS INT) AS percentile, - MIN(value) AS value - FROM percentiles_for_value - GROUP BY percentile - ORDER BY percentile ASC) -SELECT - num AS percentile, - IFNULL(value, MIN(value) OVER (ORDER BY percentile DESC)) AS value -FROM _NUMBER_GENERATOR(100) AS nums -LEFT JOIN with_gaps ON with_gaps.percentile = nums.num -ORDER BY percentile DESC; - --- All percentiles (range 1-100) for counter track ID. -CREATE PERFETTO FUNCTION counter_percentiles_for_track( - -- Id of the counter track. - counter_track_id INT) -RETURNS TABLE( - -- All of the numbers from 1 to 100. - percentile INT, - -- Value for the percentile. - value DOUBLE -) AS -SELECT * -FROM counter_percentiles_for_time_range( - $counter_track_id, trace_start(), trace_end()); - --- Value for specific percentile (range 1-100) for counter track ID in time range. -CREATE PERFETTO FUNCTION counter_track_percentile_for_time( - -- Id of the counter track. - counter_track_id INT, - -- Any of the numbers from 1 to 100. - percentile INT, - -- Timestamp of start of time range. - start_ts LONG, - -- Timestamp of end of time range. - end_ts LONG) --- Value for the percentile. -RETURNS DOUBLE AS -SELECT value -FROM counter_percentiles_for_time_range($counter_track_id, $start_ts, $end_ts) -WHERE percentile = $percentile; - --- Value for specific percentile (range 1-100) for counter track ID. -CREATE PERFETTO FUNCTION counter_track_percentile( - -- Id of the counter track. - counter_track_id INT, - -- Any of the numbers from 1 to 100. - percentile INT) --- Value for the percentile. -RETURNS DOUBLE AS -SELECT counter_track_percentile_for_time($counter_track_id, - $percentile, - trace_start(), - trace_end()); diff --git a/src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/slices.sql b/src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/slices.sql deleted file mode 100644 index 05b6b2167e..0000000000 --- a/src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/slices.sql +++ /dev/null @@ -1,133 +0,0 @@ --- --- Copyright 2022 The Android Open Source Project --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- https://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. - -INCLUDE PERFETTO MODULE slices.with_context; - --- Checks if slice has an ancestor with provided name. -CREATE PERFETTO FUNCTION has_parent_slice_with_name( - -- Id of the slice to check parents of. - id INT, - -- Name of potential ancestor slice. - parent_name STRING) --- Whether `parent_name` is a name of an ancestor slice. -RETURNS BOOL AS -SELECT EXISTS( - SELECT 1 - FROM ancestor_slice($id) - WHERE name = $parent_name - LIMIT 1 -); - --- Checks if slice has a descendant with provided name. -CREATE PERFETTO FUNCTION has_descendant_slice_with_name( - -- Id of the slice to check descendants of. - id INT, - -- Name of potential descendant slice. - descendant_name STRING -) --- Whether `descendant_name` is a name of an descendant slice. -RETURNS BOOL AS -SELECT EXISTS( - SELECT 1 - FROM descendant_slice($id) - WHERE name = $descendant_name - LIMIT 1 -); - --- Finds the end timestamp for a given slice's descendant with a given name. --- If there are multiple descendants with a given name, the function will return the --- first one, so it's most useful when working with a timeline broken down into phases, --- where each subphase can happen only once. -CREATE PERFETTO FUNCTION descendant_slice_end( - -- Id of the parent slice. - parent_id INT, - -- Name of the child with the desired end TS. - child_name STRING -) --- End timestamp of the child or NULL if it doesn't exist. -RETURNS INT AS -SELECT - CASE WHEN s.dur - IS NOT -1 THEN s.ts + s.dur - ELSE NULL - END -FROM descendant_slice($parent_id) s -WHERE s.name = $child_name -LIMIT 1; - --- Finds all slices with a direct parent with the given parent_id. -CREATE PERFETTO FUNCTION direct_children_slice( - -- Id of the parent slice. - parent_id LONG) -RETURNS TABLE( - -- Alias for `slice.id`. - id LONG, - -- Alias for `slice.type`. - type STRING, - -- Alias for `slice.ts`. - ts LONG, - -- Alias for `slice.dur`. - dur LONG, - -- Alias for `slice.category`. - category LONG, - -- Alias for `slice.name`. - name STRING, - -- Alias for `slice.track_id`. - track_id LONG, - -- Alias for `slice.depth`. - depth LONG, - -- Alias for `slice.parent_id`. - parent_id LONG, - -- Alias for `slice.arg_set_id`. - arg_set_id LONG, - -- Alias for `slice.thread_ts`. - thread_ts LONG, - -- Alias for `slice.thread_dur`. - thread_dur LONG -) AS -SELECT - slice.id, - slice.type, - slice.ts, - slice.dur, - slice.category, - slice.name, - slice.track_id, - slice.depth, - slice.parent_id, - slice.arg_set_id, - slice.thread_ts, - slice.thread_dur -FROM slice -WHERE parent_id = $parent_id; - --- Given a slice id, returns the name of the slice. -CREATE PERFETTO FUNCTION slice_name_from_id( - -- The slice id which we need the name for. - id LONG -) --- The name of slice with the given id. -RETURNS STRING AS -SELECT - name -FROM slice -WHERE $id = id; - -CREATE PERFETTO FUNCTION slice_count( - -- Name of the slices to counted. - slice_glob STRING) --- Number of slices with the name. -RETURNS INT AS -SELECT COUNT(1) FROM slice WHERE name GLOB $slice_glob; diff --git a/src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/timestamps.sql b/src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/timestamps.sql deleted file mode 100644 index bff333fb0d..0000000000 --- a/src/trace_processor/perfetto_sql/stdlib/deprecated/v42/common/timestamps.sql +++ /dev/null @@ -1,72 +0,0 @@ --- --- Copyright 2022 The Android Open Source Project --- --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- https://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. - -INCLUDE PERFETTO MODULE time.conversion; - -CREATE PERFETTO FUNCTION is_spans_overlapping( - ts1 LONG, - ts_end1 LONG, - ts2 LONG, - ts_end2 LONG) -RETURNS BOOL AS -SELECT (IIF($ts1 < $ts2, $ts2, $ts1) - < IIF($ts_end1 < $ts_end2, $ts_end1, $ts_end2)); - -CREATE PERFETTO FUNCTION spans_overlapping_dur( - ts1 LONG, - dur1 LONG, - ts2 LONG, - dur2 LONG -) -RETURNS INT AS -SELECT - CASE - WHEN $dur1 = -1 OR $dur2 = -1 THEN 0 - WHEN $ts1 + $dur1 < $ts2 OR $ts2 + $dur2 < $ts1 THEN 0 - WHEN ($ts1 >= $ts2) AND ($ts1 + $dur1 <= $ts2 + $dur2) THEN $dur1 - WHEN ($ts1 < $ts2) AND ($ts1 + $dur1 < $ts2 + $dur2) THEN $ts1 + $dur1 - $ts2 - WHEN ($ts1 > $ts2) AND ($ts1 + $dur1 > $ts2 + $dur2) THEN $ts2 + $dur2 - $ts1 - ELSE $dur2 - END; - --- Renames - -CREATE PERFETTO FUNCTION ns(nanos INT) -RETURNS INT AS -SELECT time_from_ns($nanos); - -CREATE PERFETTO FUNCTION us(micros INT) -RETURNS INT AS -SELECT time_from_us($micros); - -CREATE PERFETTO FUNCTION ms(millis INT) -RETURNS INT AS -SELECT time_from_ms($millis); - -CREATE PERFETTO FUNCTION seconds(seconds INT) -RETURNS INT AS -SELECT time_from_s($seconds); - -CREATE PERFETTO FUNCTION minutes(minutes INT) -RETURNS INT AS -SELECT time_from_min($minutes); - -CREATE PERFETTO FUNCTION hours(hours INT) -RETURNS INT AS -SELECT time_from_hours($hours); - -CREATE PERFETTO FUNCTION days(days INT) -RETURNS INT AS -SELECT time_from_days($days); diff --git a/src/trace_processor/trace_database_integrationtest.cc b/src/trace_processor/trace_database_integrationtest.cc index 8397d8dafb..b9d4c47488 100644 --- a/src/trace_processor/trace_database_integrationtest.cc +++ b/src/trace_processor/trace_database_integrationtest.cc @@ -501,7 +501,7 @@ TEST_F(TraceProcessorIntegrationTest, RestoreInitialTablesModules) { for (int repeat = 0; repeat < 3; repeat++) { ASSERT_EQ(RestoreInitialTables(), 0u); { - auto it = Query("INCLUDE PERFETTO MODULE common.timestamps;"); + auto it = Query("INCLUDE PERFETTO MODULE time.conversion;"); it.Next(); ASSERT_TRUE(it.Status().ok()); } diff --git a/test/trace_processor/diff_tests/include_index.py b/test/trace_processor/diff_tests/include_index.py index 92108dee7a..69c1bc7222 100644 --- a/test/trace_processor/diff_tests/include_index.py +++ b/test/trace_processor/diff_tests/include_index.py @@ -117,8 +117,6 @@ from diff_tests.stdlib.android.startups_tests import Startups from diff_tests.stdlib.android.tests import AndroidStdlib from diff_tests.stdlib.chrome.chrome_stdlib_testsuites import CHROME_STDLIB_TESTSUITES -from diff_tests.stdlib.common.tests import StdlibCommon -from diff_tests.stdlib.common.tests import StdlibCommon from diff_tests.stdlib.counters.tests import StdlibCounterIntervals from diff_tests.stdlib.dynamic_tables.tests import DynamicTables from diff_tests.stdlib.export.tests import ExportTests @@ -326,7 +324,6 @@ def fetch_all_diff_tests(index_path: str) -> List['testing.TestCase']: *Pkvm(index_path, 'stdlib/pkvm', 'Pkvm').fetch(), *PreludeSlices(index_path, 'stdlib/prelude', 'PreludeSlices').fetch(), *StdlibSmoke(index_path, 'stdlib', 'StdlibSmoke').fetch(), - *StdlibCommon(index_path, 'stdlib/common', 'StdlibCommon').fetch(), *Slices(index_path, 'stdlib/slices', 'Slices').fetch(), *SpanJoinLeftJoin(index_path, 'stdlib/span_join', 'SpanJoinLeftJoin').fetch(), @@ -335,7 +332,6 @@ def fetch_all_diff_tests(index_path: str) -> List['testing.TestCase']: *SpanJoinRegression(index_path, 'stdlib/span_join', 'SpanJoinRegression').fetch(), *SpanJoinSmoke(index_path, 'stdlib/span_join', 'SpanJoinSmoke').fetch(), - *StdlibCommon(index_path, 'stdlib/common', 'StdlibCommon').fetch(), *StdlibIntervals(index_path, 'stdlib/intervals', 'StdlibIntervals').fetch(), *IntervalsIntersect(index_path, 'stdlib/intervals', diff --git a/test/trace_processor/diff_tests/metrics/chrome/tests_scroll_jank.py b/test/trace_processor/diff_tests/metrics/chrome/tests_scroll_jank.py index 597cdcd317..1ce67ab5e6 100644 --- a/test/trace_processor/diff_tests/metrics/chrome/tests_scroll_jank.py +++ b/test/trace_processor/diff_tests/metrics/chrome/tests_scroll_jank.py @@ -492,7 +492,7 @@ def test_has_descendant_slice_with_name_true(self): INCLUDE PERFETTO MODULE chrome.scroll_jank.scroll_jank_v3; SELECT - HAS_DESCENDANT_SLICE_WITH_NAME( + _HAS_DESCENDANT_SLICE_WITH_NAME( (SELECT id from slice where dur = 60156000), 'SwapEndToPresentationCompositorFrame') AS has_descendant; """, @@ -510,7 +510,7 @@ def test_has_descendant_slice_with_name_false(self): INCLUDE PERFETTO MODULE chrome.scroll_jank.scroll_jank_v3; SELECT - HAS_DESCENDANT_SLICE_WITH_NAME( + _HAS_DESCENDANT_SLICE_WITH_NAME( (SELECT id from slice where dur = 77247000), 'SwapEndToPresentationCompositorFrame') AS has_descendant; """, diff --git a/test/trace_processor/diff_tests/stdlib/common/tests.py b/test/trace_processor/diff_tests/stdlib/common/tests.py deleted file mode 100644 index d103320d8f..0000000000 --- a/test/trace_processor/diff_tests/stdlib/common/tests.py +++ /dev/null @@ -1,134 +0,0 @@ -#!/usr/bin/env python3 -# Copyright (C) 2023 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License a -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from python.generators.diff_tests.testing import Path, DataPath, Metric -from python.generators.diff_tests.testing import Csv, Json, TextProto -from python.generators.diff_tests.testing import DiffTestBlueprint -from python.generators.diff_tests.testing import TestSuite - - -class StdlibCommon(TestSuite): - - def test_spans_overlapping_dur_intersect_edge(self): - return DiffTestBlueprint( - trace=TextProto(r""" - - """), - query=""" - INCLUDE PERFETTO MODULE common.timestamps; - SELECT SPANS_OVERLAPPING_DUR(0, 2, 1, 2) AS dur - """, - out=Csv(""" - "dur" - 1 - """)) - - def test_spans_overlapping_dur_intersect_edge_reversed(self): - return DiffTestBlueprint( - trace=TextProto(r""" - - """), - query=""" - INCLUDE PERFETTO MODULE common.timestamps; - SELECT SPANS_OVERLAPPING_DUR(1, 2, 0, 2) AS dur - """, - out=Csv(""" - "dur" - 1 - """)) - - def test_spans_overlapping_dur_intersect_all(self): - return DiffTestBlueprint( - trace=TextProto(r""" - - """), - query=""" - INCLUDE PERFETTO MODULE common.timestamps; - SELECT SPANS_OVERLAPPING_DUR(0, 3, 1, 1) AS dur - """, - out=Csv(""" - "dur" - 1 - """)) - - def test_spans_overlapping_dur_intersect_all_reversed(self): - return DiffTestBlueprint( - trace=TextProto(r""" - - """), - query=""" - INCLUDE PERFETTO MODULE common.timestamps; - SELECT SPANS_OVERLAPPING_DUR(1, 1, 0, 3) AS dur - """, - out=Csv(""" - "dur" - 1 - """)) - - def test_spans_overlapping_dur_no_intersect(self): - return DiffTestBlueprint( - trace=TextProto(r""" - - """), - query=""" - INCLUDE PERFETTO MODULE common.timestamps; - SELECT SPANS_OVERLAPPING_DUR(0, 1, 2, 1) AS dur - """, - out=Csv(""" - "dur" - 0 - """)) - - def test_spans_overlapping_dur_no_intersect_reversed(self): - return DiffTestBlueprint( - trace=TextProto(r""" - - """), - query=""" - INCLUDE PERFETTO MODULE common.timestamps; - SELECT SPANS_OVERLAPPING_DUR(2, 1, 0, 1) AS dur - """, - out=Csv(""" - "dur" - 0 - """)) - - def test_spans_overlapping_dur_negative_dur(self): - return DiffTestBlueprint( - trace=TextProto(r""" - - """), - query=""" - INCLUDE PERFETTO MODULE common.timestamps; - SELECT SPANS_OVERLAPPING_DUR(0, -1, 0, 1) AS dur - """, - out=Csv(""" - "dur" - 0 - """)) - - def test_spans_overlapping_dur_negative_dur_reversed(self): - return DiffTestBlueprint( - trace=TextProto(r""" - - """), - query=""" - INCLUDE PERFETTO MODULE common.timestamps; - SELECT SPANS_OVERLAPPING_DUR(0, 1, 0, -1) AS dur - """, - out=Csv(""" - "dur" - 0 - """)) diff --git a/test/trace_processor/diff_tests/stdlib/timestamps/tests.py b/test/trace_processor/diff_tests/stdlib/timestamps/tests.py index a029ce5d53..d5cc34b785 100644 --- a/test/trace_processor/diff_tests/stdlib/timestamps/tests.py +++ b/test/trace_processor/diff_tests/stdlib/timestamps/tests.py @@ -22,86 +22,60 @@ class Timestamps(TestSuite): - def test_ns(self): + def test_to_time(self): return DiffTestBlueprint( trace=TextProto(""), query=""" - INCLUDE PERFETTO MODULE common.timestamps; - SELECT ns(4) as result; - """, - out=Csv(""" - "result" - 4 - """)) - - def test_us(self): - return DiffTestBlueprint( - trace=TextProto(""), - query=""" - INCLUDE PERFETTO MODULE common.timestamps; - SELECT us(4) as result; - """, - out=Csv(""" - "result" - 4000 - """)) - - def test_ms(self): - return DiffTestBlueprint( - trace=TextProto(""), - query=""" - INCLUDE PERFETTO MODULE common.timestamps; - SELECT ms(4) as result; - """, - out=Csv(""" - "result" - 4000000 - """)) + INCLUDE PERFETTO MODULE time.conversion; - def test_seconds(self): - return DiffTestBlueprint( - trace=TextProto(""), - query=""" - INCLUDE PERFETTO MODULE common.timestamps; - SELECT seconds(4) as result; + WITH data(unit, time) AS ( + VALUES + ('ns', time_to_ns(cast_int!(1e14))), + ('us', time_to_us(cast_int!(1e14))), + ('ms', time_to_ms(cast_int!(1e14))), + ('s', time_to_s(cast_int!(1e14))), + ('min', time_to_min(cast_int!(1e14))), + ('h', time_to_hours(cast_int!(1e14))), + ('days', time_to_days(cast_int!(1e14))) + ) + SELECT * FROM data """, out=Csv(""" - "result" - 4000000000 + "unit","time" + "ns",100000000000000 + "us",100000000000 + "ms",100000000 + "s",100000 + "min",1666 + "h",27 + "days",1 """)) - def test_minutes(self): + def test_from_time(self): return DiffTestBlueprint( trace=TextProto(""), query=""" - INCLUDE PERFETTO MODULE common.timestamps; - SELECT minutes(1) as result; - """, - out=Csv(""" - "result" - 60000000000 - """)) + INCLUDE PERFETTO MODULE time.conversion; - def test_hours(self): - return DiffTestBlueprint( - trace=TextProto(""), - query=""" - INCLUDE PERFETTO MODULE common.timestamps; - SELECT hours(1) as result; + WITH data(unit, time) AS ( + VALUES + ('ns', time_from_ns(1)), + ('us', time_from_us(1)), + ('ms', time_from_ms(1)), + ('s', time_from_s(1)), + ('min', time_from_min(1)), + ('h', time_from_hours(1)), + ('days', time_from_days(1)) + ) + SELECT * FROM data """, out=Csv(""" - "result" - 3600000000000 - """)) - - def test_days(self): - return DiffTestBlueprint( - trace=TextProto(""), - query=""" - INCLUDE PERFETTO MODULE common.timestamps; - SELECT days(1) as result; - """, - out=Csv(""" - "result" - 86400000000000 - """)) + "unit","time" + "ns",1 + "us",1000 + "ms",1000000 + "s",1000000000 + "min",60000000000 + "h",3600000000000 + "days",86400000000000 + """)) \ No newline at end of file diff --git a/test/trace_processor/diff_tests/syntax/include_tests.py b/test/trace_processor/diff_tests/syntax/include_tests.py index 6c4d88af59..6316ae6609 100644 --- a/test/trace_processor/diff_tests/syntax/include_tests.py +++ b/test/trace_processor/diff_tests/syntax/include_tests.py @@ -23,121 +23,40 @@ class PerfettoInclude(TestSuite): def test_import(self): return DiffTestBlueprint( - trace=TextProto(r""" - packet { - ftrace_events { - cpu: 1 - event { - timestamp: 1000 - pid: 1 - print { - buf: "C|1000|battery_stats.data_conn|13\n" - } - } - event { - timestamp: 4000 - pid: 1 - print { - buf: "C|1000|battery_stats.data_conn|20\n" - } - } - event { - timestamp: 1000 - pid: 1 - print { - buf: "C|1000|battery_stats.audio|1\n" - } - } - } - } - """), + trace=TextProto(''), query=""" - SELECT IMPORT('common.timestamps'); + SELECT IMPORT('time.conversion'); - SELECT TRACE_START(); + SELECT 1 AS x; """, out=Csv(""" - "TRACE_START()" - 1000 + "x" + 1 """)) def test_include_perfetto_module(self): return DiffTestBlueprint( - trace=TextProto(r""" - packet { - ftrace_events { - cpu: 1 - event { - timestamp: 1000 - pid: 1 - print { - buf: "C|1000|battery_stats.data_conn|13\n" - } - } - event { - timestamp: 4000 - pid: 1 - print { - buf: "C|1000|battery_stats.data_conn|20\n" - } - } - event { - timestamp: 1000 - pid: 1 - print { - buf: "C|1000|battery_stats.audio|1\n" - } - } - } - } - """), + trace=TextProto(''), query=""" - INCLUDE PERFETTO MODULE common.timestamps; + INCLUDE PERFETTO MODULE time.conversion; - SELECT TRACE_START(); + SELECT time_to_ns(1) AS x """, out=Csv(""" - "TRACE_START()" - 1000 + "x" + 1 """)) def test_include_and_import(self): return DiffTestBlueprint( - trace=TextProto(r""" - packet { - ftrace_events { - cpu: 1 - event { - timestamp: 1000 - pid: 1 - print { - buf: "C|1000|battery_stats.data_conn|13\n" - } - } - event { - timestamp: 4000 - pid: 1 - print { - buf: "C|1000|battery_stats.data_conn|20\n" - } - } - event { - timestamp: 1000 - pid: 1 - print { - buf: "C|1000|battery_stats.audio|1\n" - } - } - } - } - """), + trace=TextProto(''), query=""" - SELECT IMPORT('common.timestamps'); - INCLUDE PERFETTO MODULE common.timestamps; + SELECT IMPORT('time.conversion'); + INCLUDE PERFETTO MODULE time.conversion; - SELECT TRACE_START(); + SELECT 1 AS x """, out=Csv(""" - "TRACE_START()" - 1000 + "x" + 1 """)) diff --git a/tools/check_sql_modules.py b/tools/check_sql_modules.py index f787143599..ed8ddc3cdd 100755 --- a/tools/check_sql_modules.py +++ b/tools/check_sql_modules.py @@ -106,7 +106,10 @@ def main(): if (include_package == "common"): errors.append( - "Common module has been deprecated in the standard library.") + "Common module has been deprecated in the standard library. " + "Please check `slices.with_context` for a replacement for " + "`common.slices` and `time.conversion` for replacement for " + "`common.timestamps`") if (package != "viz" and include_package == "viz"): errors.append("No modules can depend on 'viz' outside 'viz' package.")