Extract jank classification between app/sf in std lib
Updated query in jank frames to use function from jank.sql
Tests: Called within android_jank_cuj.sql covered by android_jank_cuj.py diff test
Change-Id: Ia25af8dc989fdbe08e2e5edf24b4b9ee6e1cd462
diff --git a/Android.bp b/Android.bp
index 09c661a..e778900 100644
--- a/Android.bp
+++ b/Android.bp
@@ -13108,6 +13108,7 @@
"src/trace_processor/perfetto_sql/stdlib/android/critical_blocking_calls.sql",
"src/trace_processor/perfetto_sql/stdlib/android/device.sql",
"src/trace_processor/perfetto_sql/stdlib/android/dvfs.sql",
+ "src/trace_processor/perfetto_sql/stdlib/android/frames/jank_type.sql",
"src/trace_processor/perfetto_sql/stdlib/android/frames/per_frame_metrics.sql",
"src/trace_processor/perfetto_sql/stdlib/android/frames/timeline.sql",
"src/trace_processor/perfetto_sql/stdlib/android/frames/timeline_maxsdk28.sql",
diff --git a/BUILD b/BUILD
index d336746..0f6b647 100644
--- a/BUILD
+++ b/BUILD
@@ -2509,6 +2509,7 @@
perfetto_filegroup(
name = "src_trace_processor_perfetto_sql_stdlib_android_frames_frames",
srcs = [
+ "src/trace_processor/perfetto_sql/stdlib/android/frames/jank_type.sql",
"src/trace_processor/perfetto_sql/stdlib/android/frames/per_frame_metrics.sql",
"src/trace_processor/perfetto_sql/stdlib/android/frames/timeline.sql",
"src/trace_processor/perfetto_sql/stdlib/android/frames/timeline_maxsdk28.sql",
diff --git a/src/trace_processor/metrics/sql/android/jank/frames.sql b/src/trace_processor/metrics/sql/android/jank/frames.sql
index ef47b1c..8f72e96 100644
--- a/src/trace_processor/metrics/sql/android/jank/frames.sql
+++ b/src/trace_processor/metrics/sql/android/jank/frames.sql
@@ -13,6 +13,8 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
+INCLUDE PERFETTO MODULE android.frames.jank_type;
+
DROP TABLE IF EXISTS vsync_missed_callback;
CREATE PERFETTO TABLE vsync_missed_callback AS
SELECT CAST(STR_SPLIT(name, 'Callback#', 1) AS INTEGER) AS vsync,
@@ -35,14 +37,9 @@
cuj_id,
vsync,
-- We use MAX to check if at least one of the layers jank_type matches the pattern
- MAX(jank_type GLOB '*App Deadline Missed*') AS app_missed,
+ MAX(android_is_app_jank_type(jank_type)) AS app_missed,
-- We use MAX to check if at least one of the layers jank_type matches the pattern
- MAX(
- jank_type GLOB '*SurfaceFlinger CPU Deadline Missed*'
- OR jank_type GLOB '*SurfaceFlinger GPU Deadline Missed*'
- OR jank_type GLOB '*SurfaceFlinger Scheduling*'
- OR jank_type GLOB '*Prediction Error*'
- OR jank_type GLOB '*Display HAL*') AS sf_missed,
+ MAX(android_is_sf_jank_type(jank_type)) AS sf_missed,
IFNULL(MAX(sf_callback_missed), 0) AS sf_callback_missed,
IFNULL(MAX(hwui_callback_missed), 0) AS hwui_callback_missed,
-- We use MIN to check if ALL layers finished on time
diff --git a/src/trace_processor/perfetto_sql/stdlib/android/frames/BUILD.gn b/src/trace_processor/perfetto_sql/stdlib/android/frames/BUILD.gn
index 306758a..4c1708b 100644
--- a/src/trace_processor/perfetto_sql/stdlib/android/frames/BUILD.gn
+++ b/src/trace_processor/perfetto_sql/stdlib/android/frames/BUILD.gn
@@ -16,6 +16,7 @@
perfetto_sql_source_set("frames") {
sources = [
+ "jank_type.sql",
"per_frame_metrics.sql",
"timeline.sql",
"timeline_maxsdk28.sql",
diff --git a/src/trace_processor/perfetto_sql/stdlib/android/frames/jank_type.sql b/src/trace_processor/perfetto_sql/stdlib/android/frames/jank_type.sql
new file mode 100644
index 0000000..156c5b9
--- /dev/null
+++ b/src/trace_processor/perfetto_sql/stdlib/android/frames/jank_type.sql
@@ -0,0 +1,38 @@
+--
+-- Copyright 2024 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.
+
+-- Categorizes whether the jank was caused by Surface Flinger
+CREATE PERFETTO FUNCTION android_is_sf_jank_type(
+ -- the jank type
+ -- from args.display_value with key = "Jank type"
+ jank_type STRING)
+-- True when the jank type represents sf jank
+RETURNS BOOL AS
+SELECT
+ $jank_type GLOB '*SurfaceFlinger CPU Deadline Missed*'
+ OR $jank_type GLOB '*SurfaceFlinger GPU Deadline Missed*'
+ OR $jank_type GLOB '*SurfaceFlinger Scheduling*'
+ OR $jank_type GLOB '*Prediction Error*'
+ OR $jank_type GLOB '*Display HAL*';
+
+
+-- Categorizes whether the jank was caused by the app
+CREATE PERFETTO FUNCTION android_is_app_jank_type(
+ -- the jank type
+ -- from args.display_value with key = "Jank type"
+ jank_type STRING)
+-- True when the jank type represents app jank
+RETURNS BOOL AS
+SELECT $jank_type GLOB '*App Deadline Missed*';
\ No newline at end of file