• 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
16SELECT RUN_METRIC('chrome/chrome_input_to_browser_intervals.sql');
17
18-- Script params:
19-- {{dur_causes_jank_ms}} : The duration of a task barrage on the Chrome
20-- main thread that will delay input causing jank.
21
22-- Filter intervals to only durations longer than {{dur_causes_jank_ms}}.
23DROP VIEW IF EXISTS chrome_input_to_browser_longer_intervals;
24CREATE VIEW chrome_input_to_browser_longer_intervals AS
25SELECT
26  *
27FROM chrome_input_to_browser_intervals
28WHERE
29  (window_end_ts - window_start_ts) >= {{dur_causes_jank_ms}} * 1e6;
30
31-- Assign tasks to each delay interval that we could have started
32-- processing input but didn't on the main thread, and sum those
33-- tasks.
34-- We filter java out here as we're interested in tasks that delayed
35-- yielding to java native work, and we filter tasks that are more
36-- than 8ms here as those are handled separately and are not regarded
37-- as scheduling issues.
38DROP VIEW IF EXISTS chrome_task_barrages_per_interval;
39CREATE VIEW chrome_task_barrages_per_interval AS
40SELECT
41  GROUP_CONCAT(DISTINCT full_name) AS full_name,
42  SUM(dur / 1e6) AS total_duration_ms,
43  SUM(thread_dur / 1e6) AS total_thread_duration_ms,
44  MIN(id) AS first_id_per_task_barrage,
45  MAX(id) AS last_id_per_task_barrage,
46  COUNT(*) AS count,
47  window_start_id,
48  window_start_ts,
49  window_end_id,
50  window_end_ts,
51  scroll_type
52FROM
53  (
54    SELECT * FROM (
55      SELECT
56        chrome_tasks.full_name AS full_name,
57        chrome_tasks.dur AS dur,
58        chrome_tasks.thread_dur AS thread_dur,
59        chrome_tasks.ts AS ts,
60        chrome_tasks.id,
61        chrome_tasks.upid
62      FROM
63        chrome_tasks
64      WHERE
65        chrome_tasks.thread_name = "CrBrowserMain"
66        AND task_type != "java"
67        AND task_type != "choreographer"
68      ORDER BY chrome_tasks.ts
69    ) tasks
70    JOIN chrome_input_to_browser_longer_intervals
71      ON (tasks.ts + tasks.dur)
72        > chrome_input_to_browser_longer_intervals.window_start_ts
73        AND (tasks.ts + tasks.dur)
74        < chrome_input_to_browser_longer_intervals.window_end_ts
75        AND tasks.ts > chrome_input_to_browser_longer_intervals.window_start_ts
76        AND tasks.ts < chrome_input_to_browser_longer_intervals.window_end_ts
77        -- For cases when there are multiple chrome instances.
78        AND tasks.upid = chrome_input_to_browser_longer_intervals.upid
79    ORDER BY window_start_ts, window_end_ts
80  )
81GROUP BY window_start_ts, window_end_ts;
82
83-- Filter to task barrages that took more than 8ms, as barrages
84-- that lasted less than that are unlikely to have caused jank.
85DROP VIEW IF EXISTS chrome_scroll_jank_caused_by_scheduling;
86CREATE VIEW chrome_scroll_jank_caused_by_scheduling AS
87SELECT *
88FROM chrome_task_barrages_per_interval
89WHERE total_duration_ms > {{dur_causes_jank_ms}} AND count > 1
90ORDER BY total_duration_ms DESC;
91