• 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;
17INCLUDE PERFETTO MODULE viz.summary.threads;
18
19CREATE PERFETTO TABLE _process_track_summary AS
20SELECT upid, SUM(cnt) AS slice_count
21FROM process_track
22JOIN _slice_track_summary USING (id)
23GROUP BY upid;
24
25CREATE PERFETTO TABLE _heap_profile_allocation_summary AS
26SELECT upid, COUNT() AS allocation_count
27FROM heap_profile_allocation
28GROUP BY upid;
29
30CREATE PERFETTO TABLE _heap_profile_graph_summary AS
31SELECT upid, COUNT() AS graph_object_count
32FROM heap_graph_object;
33
34CREATE PERFETTO TABLE _thread_process_grouped_summary AS
35SELECT
36  upid,
37  MAX(max_running_dur) AS max_running_dur,
38  SUM(sum_running_dur) AS sum_running_dur,
39  SUM(running_count) AS running_count,
40  SUM(slice_count) AS slice_count,
41  SUM(perf_sample_count) AS perf_sample_count
42FROM _thread_available_info_summary
43JOIN thread USING (utid)
44WHERE upid IS NOT NULL
45GROUP BY upid;
46
47CREATE PERFETTO TABLE _process_available_info_summary AS
48WITH r AS (
49  SELECT
50    upid,
51    t_summary.upid as summary_upid,
52    t_summary.max_running_dur AS max_running_dur,
53    t_summary.sum_running_dur,
54    t_summary.running_count,
55    t_summary.slice_count AS thread_slice_count,
56    t_summary.perf_sample_count AS perf_sample_count,
57    (
58      SELECT slice_count
59      FROM _process_track_summary
60      WHERE upid = p.upid
61    ) AS process_slice_count,
62    (
63      SELECT allocation_count
64      FROM _heap_profile_allocation_summary
65      WHERE upid = p.upid
66    ) AS allocation_count,
67    (
68      SELECT graph_object_count
69      FROM _heap_profile_graph_summary
70      WHERE upid = p.upid
71    ) AS graph_object_count
72  FROM process p
73  LEFT JOIN _thread_process_grouped_summary t_summary USING (upid)
74)
75SELECT
76  upid,
77  IFNULL(max_running_dur, 0) AS max_running_dur,
78  IFNULL(sum_running_dur, 0) AS sum_running_dur,
79  IFNULL(running_count, 0) AS running_count,
80  IFNULL(thread_slice_count, 0) AS thread_slice_count,
81  IFNULL(perf_sample_count, 0) AS perf_sample_count,
82  IFNULL(process_slice_count, 0) AS process_slice_count,
83  IFNULL(allocation_count, 0) AS allocation_count,
84  IFNULL(graph_object_count, 0) AS graph_object_count
85FROM r
86WHERE
87  NOT(
88    r.summary_upid IS NULL
89    AND process_slice_count IS NULL
90    AND allocation_count IS NULL
91    AND graph_object_count IS NULL
92  )
93  OR upid IN (SELECT upid FROM process_counter_track);
94