• 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
16DROP VIEW IF EXISTS android_jank_cuj_slice;
17CREATE VIEW android_jank_cuj_slice AS
18SELECT
19  cuj_id,
20  process.upid,
21  process.name AS process_name,
22  thread.utid,
23  thread.name AS thread_name,
24  slice.*,
25  slice.ts + slice.dur AS ts_end
26FROM android_jank_cuj_boundary boundary
27JOIN process USING (upid)
28JOIN thread USING (upid)
29JOIN thread_track USING (utid)
30JOIN slice
31  ON slice.track_id = thread_track.id
32    -- Take slices which overlap even they started before the boundaries
33    -- This is to be able to query slices that delayed start of a frame
34    AND slice.ts + slice.dur >= boundary.ts AND slice.ts <= boundary.ts_end
35WHERE slice.dur > 0;
36
37DROP TABLE IF EXISTS android_jank_cuj_main_thread_slice;
38CREATE TABLE android_jank_cuj_main_thread_slice AS
39SELECT
40  cuj_id,
41  upid,
42  utid,
43  slice.*,
44  slice.ts + slice.dur AS ts_end
45FROM android_jank_cuj_main_thread_cuj_boundary boundary
46JOIN thread_track USING (utid)
47JOIN thread USING (utid)
48JOIN slice
49  ON slice.track_id = thread_track.id
50    -- Take slices which overlap even they started before the boundaries
51    -- This is to be able to query slices that delayed start of a frame
52    AND slice.ts + slice.dur >= boundary.ts
53    AND slice.ts <= boundary.ts_end
54WHERE slice.dur > 0;
55
56DROP TABLE IF EXISTS android_jank_cuj_render_thread_slice;
57CREATE TABLE android_jank_cuj_render_thread_slice AS
58SELECT
59  cuj_id,
60  upid,
61  utid,
62  slice.*,
63  slice.ts + slice.dur AS ts_end
64FROM android_jank_cuj_render_thread_cuj_boundary boundary
65JOIN thread_track USING (utid)
66JOIN thread USING (utid)
67JOIN slice
68  ON slice.track_id = thread_track.id
69    -- Take slices which overlap even they started before the boundaries
70    -- This is to be able to query slices that delayed start of a frame
71    AND slice.ts + slice.dur >= boundary.ts
72    AND slice.ts <= boundary.ts_end
73WHERE slice.dur > 0;
74
75DROP VIEW IF EXISTS android_jank_cuj_sf_slice;
76CREATE VIEW android_jank_cuj_sf_slice AS
77SELECT
78  cuj_id,
79  upid,
80  sf_process.name AS process_name,
81  thread.utid,
82  thread.name AS thread_name,
83  slice.*,
84  slice.ts + slice.dur AS ts_end
85FROM android_jank_cuj_sf_boundary sf_boundary
86JOIN android_jank_cuj_sf_process sf_process
87JOIN thread USING (upid)
88JOIN thread_track USING (utid)
89JOIN slice
90  ON slice.track_id = thread_track.id
91    -- Take slices which overlap even they started before the boundaries
92    -- This is to be able to query slices that delayed start of a frame
93    AND slice.ts + slice.dur >= sf_boundary.ts AND slice.ts <= sf_boundary.ts_end
94WHERE slice.dur > 0;
95
96DROP TABLE IF EXISTS android_jank_cuj_sf_main_thread_slice;
97CREATE TABLE android_jank_cuj_sf_main_thread_slice AS
98SELECT
99  cuj_id,
100  upid,
101  utid,
102  slice.*,
103  slice.ts + slice.dur AS ts_end
104FROM android_jank_cuj_sf_main_thread_cuj_boundary boundary
105JOIN thread_track USING (utid)
106JOIN thread USING (utid)
107JOIN slice
108  ON slice.track_id = thread_track.id
109    -- Take slices which overlap even they started before the boundaries
110    -- This is to be able to query slices that delayed start of a frame
111    AND slice.ts + slice.dur >= boundary.ts
112    AND slice.ts <= boundary.ts_end
113WHERE slice.dur > 0;
114
115-- For RenderEngine thread we use a different approach as it's only used when SF falls back to
116-- client composition. Instead of taking all slices during CUJ, we look at each frame explicitly
117-- and only take slices that are within RenderEngine frame boundaries.
118DROP TABLE IF EXISTS android_jank_cuj_sf_render_engine_slice;
119CREATE TABLE android_jank_cuj_sf_render_engine_slice AS
120SELECT
121  cuj_id,
122  upid,
123  utid,
124  slice.*,
125  slice.ts + slice.dur AS ts_end
126FROM android_jank_cuj_sf_render_engine_frame_boundary boundary
127JOIN thread_track USING (utid)
128JOIN thread USING (utid)
129JOIN slice
130  ON slice.track_id = thread_track.id
131    -- Take slices which overlap even they started before the boundaries
132    -- This is to be able to query slices that delayed start of a frame
133    AND slice.ts + slice.dur >= boundary.ts
134    AND slice.ts <= boundary.ts_end
135WHERE slice.dur > 0;
136