• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1--
2-- Copyright 2024 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
16INCLUDE PERFETTO MODULE viz.summary.slices;
17
18INCLUDE PERFETTO MODULE viz.summary.threads;
19
20CREATE PERFETTO TABLE _process_track_summary AS
21SELECT
22  upid,
23  sum(cnt) AS slice_count
24FROM process_track
25JOIN _slice_track_summary
26  USING (id)
27GROUP BY
28  upid;
29
30CREATE PERFETTO TABLE _heap_profile_allocation_summary AS
31SELECT
32  upid,
33  count() AS allocation_count
34FROM heap_profile_allocation
35GROUP BY
36  upid;
37
38CREATE PERFETTO TABLE _heap_profile_graph_summary AS
39SELECT
40  upid,
41  count() AS graph_object_count
42FROM heap_graph_object
43GROUP BY
44  upid;
45
46CREATE PERFETTO TABLE _thread_process_grouped_summary AS
47SELECT
48  upid,
49  max(max_running_dur) AS max_running_dur,
50  sum(sum_running_dur) AS sum_running_dur,
51  sum(running_count) AS running_count,
52  sum(slice_count) AS slice_count,
53  sum(perf_sample_count) AS perf_sample_count,
54  sum(instruments_sample_count) AS instruments_sample_count
55FROM _thread_available_info_summary
56JOIN thread
57  USING (utid)
58WHERE
59  upid IS NOT NULL
60GROUP BY
61  upid;
62
63CREATE PERFETTO TABLE _process_available_info_summary AS
64WITH
65  r AS (
66    SELECT
67      upid,
68      t_summary.upid AS summary_upid,
69      t_summary.max_running_dur AS max_running_dur,
70      t_summary.sum_running_dur,
71      t_summary.running_count,
72      t_summary.slice_count AS thread_slice_count,
73      t_summary.perf_sample_count AS perf_sample_count,
74      t_summary.instruments_sample_count AS instruments_sample_count,
75      (
76        SELECT
77          slice_count
78        FROM _process_track_summary
79        WHERE
80          upid = p.upid
81      ) AS process_slice_count,
82      (
83        SELECT
84          allocation_count
85        FROM _heap_profile_allocation_summary
86        WHERE
87          upid = p.upid
88      ) AS allocation_count,
89      (
90        SELECT
91          graph_object_count
92        FROM _heap_profile_graph_summary
93        WHERE
94          upid = p.upid
95      ) AS graph_object_count
96    FROM process AS p
97    LEFT JOIN _thread_process_grouped_summary AS t_summary
98      USING (upid)
99  )
100SELECT
101  upid,
102  coalesce(max_running_dur, 0) AS max_running_dur,
103  coalesce(sum_running_dur, 0) AS sum_running_dur,
104  coalesce(running_count, 0) AS running_count,
105  coalesce(thread_slice_count, 0) AS thread_slice_count,
106  coalesce(perf_sample_count, 0) AS perf_sample_count,
107  coalesce(instruments_sample_count, 0) AS instruments_sample_count,
108  coalesce(process_slice_count, 0) AS process_slice_count,
109  coalesce(allocation_count, 0) AS allocation_count,
110  coalesce(graph_object_count, 0) AS graph_object_count
111FROM r
112WHERE
113  NOT (
114    r.summary_upid IS NULL
115    AND process_slice_count IS NULL AND allocation_count IS NULL AND graph_object_count IS NULL
116  )
117  OR upid IN (
118    SELECT
119      upid
120    FROM process_counter_track
121  );
122