1-- 2-- Copyright 2022 The Android Open Source Project 3-- 4-- Licensed under the Apache License, Version 2.0 (the "License"); 5-- you may not use this file except in compliance with the License. 6-- You may obtain a copy of the License at 7-- 8-- https://www.apache.org/licenses/LICENSE-2.0 9-- 10-- Unless required by applicable law or agreed to in writing, software 11-- distributed under the License is distributed on an "AS IS" BASIS, 12-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13-- See the License for the specific language governing permissions and 14-- limitations under the License. 15 16 17-- Consider calling ANDROID_JANK_CORRELATE_FRAME_SLICE which passes a default value for 18-- `table_name_prefix`. 19-- 20-- Matches slices with frames within CUJs and aggregates slices durations within each frame. 21-- This allows comparing the cumulative durations of a set of slices vs what was the expected 22-- duration of each frame. It can be a useful heuristic to figure out what contributed to 23-- frames missing their expected deadlines. 24-- 25-- For more details see the documentation in query_frame_slice.sql. 26-- 27-- Example usage: 28-- 29-- CREATE VIEW example_table AS 30-- SELECT * FROM android_jank_cuj_slice WHERE name = 'binder transaction'; 31-- SELECT ANDROID_JANK_CORRELATE_FRAME_SLICE_IMPL('MainThread', 'example_table', 'jank_query'); 32-- SELECT * FROM jank_query_slice_in_frame_agg; 33-- 34-- Function arguments: 35-- 36-- table_set - Name of a set of tables from `android_jank_cuj_table_set`. 37-- Groups releated tables to simplify passing them as arguments to functions. 38-- 39-- relevant_slice_table_name - Table or View which selects slices for analysis from the 40-- `android_jank_cuj_slice` table. 41-- 42-- table_name_prefix - Running the function will create multiple tables. This value will be used 43-- as a prefx for their names to avoid name collisions with other tables. 44SELECT CREATE_FUNCTION( 45 'ANDROID_JANK_CORRELATE_FRAME_SLICE_IMPL(table_set STRING, relevant_slice_table_name STRING, table_name_prefix STRING)', 46 'STRING', 47 ' 48 SELECT COALESCE( -- COALESCE to return the text with table names to the caller instead of NULL 49 RUN_METRIC( 50 "android/jank/internal/query_frame_slice.sql", 51 "table_name_prefix", $table_name_prefix, 52 "relevant_slice_table_name", $relevant_slice_table_name, 53 "slice_table_name", (SELECT ANDROID_JANK_CUJ_TABLE_SET_SLICE($table_set)), 54 "frame_boundary_table_name", (SELECT ANDROID_JANK_CUJ_TABLE_SET_FRAME_BOUNDARY($table_set)), 55 "frame_table_name", (SELECT ANDROID_JANK_CUJ_TABLE_SET_FRAME($table_set))), 56 "Query results in `" || $table_name_prefix || "_slice_in_frame_agg` and `" || $table_name_prefix || "_slice_in_frame`.") 57 ' 58); 59 60 61-- Provides a default value for table_name_prefix in ANDROID_JANK_CORRELATE_FRAME_SLICE_IMPL. 62-- See documentation for ANDROID_JANK_CORRELATE_FRAME_SLICE_IMPL. 63SELECT CREATE_FUNCTION( 64 'ANDROID_JANK_CORRELATE_FRAME_SLICE(table_set STRING, relevant_slice_table_name STRING)', 65 'STRING', 66 'SELECT ANDROID_JANK_CORRELATE_FRAME_SLICE_IMPL($table_set, $relevant_slice_table_name, "jank_query")' 67); 68