• 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
17SELECT RUN_METRIC('android/process_metadata.sql') AS unused;
18
19DROP VIEW IF EXISTS profiler_smaps_output;
20CREATE VIEW profiler_smaps_output AS
21WITH base_stat_counts AS (
22  SELECT
23    ts,
24    upid,
25    path,
26    SUM(size_kb) AS size_kb,
27    SUM(private_dirty_kb) AS private_dirty_kb,
28    SUM(swap_kb) AS swap_kb
29  FROM profiler_smaps
30  GROUP BY 1, 2, 3
31  ORDER BY 4 DESC
32),
33mapping_protos AS (
34  SELECT
35    ts,
36    upid,
37    RepeatedField(ProfilerSmaps_Mapping(
38        'path', path,
39        'size_kb', size_kb,
40        'private_dirty_kb', private_dirty_kb,
41        'swap_kb', swap_kb
42      )) AS mappings
43  FROM base_stat_counts
44  GROUP BY 1, 2
45)
46SELECT ProfilerSmaps(
47    'instance', RepeatedField(
48      ProfilerSmaps_Instance(
49        'process', process_metadata.metadata,
50        'mappings', mappings
51      ))
52  )
53FROM mapping_protos JOIN process_metadata USING (upid);
54