• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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-- Script params:
17-- {{duration_causing_jank_ms}} : The duration of a single task that would cause
18-- jank, by delaying input from being handled on the main thread.
19-- {{task_table_name}} : The table tracking chrome tasks which will be used to
20-- determine which chrome tasks are causing the delay. One of chrome_tasks or
21-- chrome_long_tasks.
22-- {{input_browser_interval_table_name}} : The table tracking chrome input to
23-- browser interval. This may differ based on whether the scenario is for
24-- topLevel events or LongTask events.
25
26SELECT CREATE_VIEW_FUNCTION(
27  '{{function_prefix}}SELECT_SLOW_BROWSER_TASKS()',
28  'full_name STRING, dur INT, ts INT, id INT, upid INT, thread_dur INT',
29  'SELECT
30    task_table.full_name AS full_name,
31    task_table.dur AS dur,
32    task_table.ts AS ts,
33    task_table.id AS id,
34    task_table.upid AS upid,
35    thread_dur
36  FROM
37    {{task_table_name}} task_table
38  WHERE
39    task_table.dur >= {{duration_causing_jank_ms}} * 1e6
40    AND task_table.thread_name = "CrBrowserMain"
41  '
42);
43
44-- Get the tasks that was running for more than 8ms within windows
45-- that we could have started processing input but did not on the
46-- main thread, because it was blocked by those tasks.
47DROP VIEW IF EXISTS chrome_tasks_delaying_input_processing_unaggregated;
48CREATE VIEW chrome_tasks_delaying_input_processing_unaggregated AS
49SELECT
50  tasks.full_name AS full_name,
51  tasks.dur / 1e6 AS duration_ms,
52  id AS slice_id,
53  thread_dur / 1e6 AS thread_dur_ms,
54  input_tbl.window_start_id,
55  input_tbl.window_end_id
56FROM ({{function_prefix}}SELECT_SLOW_BROWSER_TASKS()) tasks
57JOIN {{input_browser_interval_table_name}} input_tbl
58  ON tasks.ts + tasks.dur > input_tbl.window_start_ts
59    AND tasks.ts + tasks.dur < input_tbl.window_end_ts
60    AND tasks.upid = input_tbl.upid;
61
62-- Same task can delay multiple GestureUpdates, this step dedups
63-- multiple occrences of the same slice_id
64DROP VIEW IF EXISTS chrome_tasks_delaying_input_processing;
65CREATE VIEW chrome_tasks_delaying_input_processing AS
66SELECT
67  full_name,
68  duration_ms,
69  slice_id,
70  thread_dur_ms
71FROM chrome_tasks_delaying_input_processing_unaggregated
72GROUP BY slice_id;
73
74-- Get the tasks that were running for more than 8ms within windows
75-- that we could have started processing input but did not on the
76-- main thread, because it was blocked by those tasks.
77DROP VIEW IF EXISTS chrome_tasks_delaying_input_processing_summary;
78CREATE VIEW chrome_tasks_delaying_input_processing_summary AS
79SELECT
80  full_name AS full_name,
81  AVG(duration_ms) AS avg_duration_ms,
82  AVG(thread_dur_ms) AS avg_thread_duration_ms,
83  MIN(duration_ms) AS min_task_duration,
84  MAX(duration_ms) AS max_task_duration,
85  SUM(duration_ms) AS total_duration_ms,
86  SUM(thread_dur_ms) AS total_thread_duration_ms,
87  GROUP_CONCAT(slice_id, '-') AS slice_ids,
88  COUNT(*) AS count
89FROM
90  chrome_tasks_delaying_input_processing
91GROUP BY
92  full_name;
93