• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1--
2-- Copyright 2019 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
17DROP TABLE IF EXISTS {{table_name}}_by_priority_stats;
18CREATE PERFETTO TABLE {{table_name}}_by_priority_stats AS
19SELECT
20  process.name AS process_name,
21  CASE
22    WHEN oom_score_val < -900 THEN 'native'
23    WHEN oom_score_val < -800 THEN 'system'
24    WHEN oom_score_val < -700 THEN 'persistent'
25    WHEN oom_score_val < 0 THEN 'persistent_service'
26    WHEN oom_score_val < 100 THEN 'foreground'
27    WHEN oom_score_val < 200 THEN 'visible'
28    WHEN oom_score_val < 300 THEN 'perceptible'
29    WHEN oom_score_val < 400 THEN 'backup'
30    WHEN oom_score_val < 500 THEN 'heavy_weight'
31    WHEN oom_score_val < 600 THEN 'service_a'
32    WHEN oom_score_val < 700 THEN 'home'
33    WHEN oom_score_val < 800 THEN 'prev'
34    WHEN oom_score_val < 900 THEN 'service_b'
35    ELSE 'cached'
36  END AS priority,
37  MIN(span.{{table_name}}_val) AS min_value,
38  MAX(span.{{table_name}}_val) AS max_value,
39  SUM(span.{{table_name}}_val * span.dur) / SUM(span.dur) AS avg_value
40FROM {{table_name}}_by_oom_span AS span JOIN process USING(upid)
41WHERE process.name IS NOT NULL
42GROUP BY 1, 2
43ORDER BY 1, 2;
44
45DROP VIEW IF EXISTS {{table_name}}_by_priority_stats_proto;
46CREATE PERFETTO VIEW {{table_name}}_by_priority_stats_proto AS
47SELECT
48  process_name,
49  priority,
50  AndroidMemoryMetric_Counter(
51    'min', min_value,
52    'max', max_value,
53    'avg', avg_value
54  ) AS proto
55FROM {{table_name}}_by_priority_stats;
56