• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1--
2-- Copyright 2021 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-- Find all dropped frames, i.e. all PipelineReporters slices whose
17-- state is 'STATE_DROPPED'.
18DROP VIEW IF EXISTS dropped_pipeline_reporter_slice;
19CREATE VIEW dropped_pipeline_reporter_slice AS
20SELECT slice.* FROM slice
21JOIN args
22  ON slice.arg_set_id = args.arg_set_id
23WHERE
24  slice.name = 'PipelineReporter'
25  AND args.string_value = 'STATE_DROPPED';
26
27-- Find the upid of the proccesses where the dropped frames occur.
28DROP VIEW IF EXISTS dropped_frames_with_upid;
29CREATE VIEW dropped_frames_with_upid AS
30SELECT
31  dropped_pipeline_reporter_slice.ts,
32  process_track.upid
33FROM dropped_pipeline_reporter_slice
34JOIN process_track
35  ON dropped_pipeline_reporter_slice.track_id = process_track.id;
36
37-- Find the name and pid of the processes.
38-- If the process name represents a file's pathname, the path part will be
39-- removed from the display name of the process.
40DROP VIEW IF EXISTS dropped_frames_with_process_info;
41CREATE VIEW dropped_frames_with_process_info AS
42SELECT
43  dropped_frames_with_upid.ts,
44  REPLACE(
45    process.name,
46    RTRIM(
47      process.name,
48      REPLACE(process.name, '/', '')
49    ),
50    '') AS process_name,
51  process.pid AS process_id
52FROM dropped_frames_with_upid
53JOIN process
54  ON dropped_frames_with_upid.upid = process.upid;
55
56-- Create the derived event track for dropped frames.
57-- All tracks generated from chrome_dropped_frames_event are
58-- placed under a track group named 'Dropped Frames', whose summary
59-- track is the first track ('All Processes') in chrome_dropped_frames_event.
60-- Note that the 'All Processes' track is generated only when dropped frames
61-- come from more than one origin process.
62DROP VIEW IF EXISTS chrome_dropped_frames_event;
63CREATE VIEW chrome_dropped_frames_event AS
64SELECT
65  'slice' AS track_type,
66  'All Processes' AS track_name,
67  ts,
68  0 AS dur,
69  'Dropped Frame' AS slice_name,
70  'Dropped Frames' AS group_name
71FROM dropped_frames_with_process_info
72WHERE (SELECT COUNT(DISTINCT process_id)
73                    FROM dropped_frames_with_process_info) > 1
74GROUP BY ts
75UNION ALL
76SELECT
77  'slice' AS track_type,
78  COALESCE(process_name, 'Process') || ' ' || process_id AS track_name,
79  ts,
80  0 AS dur,
81  'Dropped Frame' AS slice_name,
82  'Dropped Frames' AS group_name
83FROM dropped_frames_with_process_info
84GROUP BY process_id, ts;
85
86-- Create the dropped frames metric output.
87DROP VIEW IF EXISTS chrome_dropped_frames_output;
88CREATE VIEW chrome_dropped_frames_output AS
89SELECT ChromeDroppedFrames(
90  'dropped_frame', (
91    SELECT RepeatedField(
92      ChromeDroppedFrames_DroppedFrame(
93        'ts', ts,
94        'process_name', process_name,
95        'pid', process_id
96      )
97    )
98    FROM dropped_frames_with_process_info
99    ORDER BY ts
100  )
101);
102