• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1--
2-- Copyright 2022 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
16DROP VIEW IF EXISTS irq_runtime_all;
17
18CREATE VIEW irq_runtime_all
19AS
20SELECT ts, dur, name
21FROM slice
22WHERE category = 'irq';
23
24DROP VIEW IF EXISTS hw_irq_runtime;
25
26CREATE VIEW hw_irq_runtime
27AS
28SELECT ts, dur, name
29FROM irq_runtime_all
30WHERE name GLOB 'IRQ (*)'
31ORDER BY dur DESC;
32
33DROP VIEW IF EXISTS hw_irq_runtime_statistics;
34
35CREATE VIEW hw_irq_runtime_statistics
36AS
37SELECT
38  MAX(dur) AS max_runtime,
39  COUNT(IIF(dur > 1e6, 1, NULL)) AS over_threshold_count,
40  COUNT(*) AS total_count
41FROM hw_irq_runtime;
42
43DROP VIEW IF EXISTS sw_irq_runtime;
44
45CREATE VIEW sw_irq_runtime
46AS
47SELECT ts, dur, name
48FROM irq_runtime_all
49WHERE name NOT GLOB 'IRQ (*)'
50ORDER BY dur DESC;
51
52CREATE VIEW sw_irq_runtime_statistics
53AS
54SELECT
55  MAX(dur) AS max_runtime,
56  COUNT(IIF(dur > 5e6, 1, NULL)) AS over_threshold_count,
57  COUNT(*) AS total_count
58FROM sw_irq_runtime;
59
60DROP VIEW IF EXISTS android_irq_runtime_output;
61
62CREATE VIEW android_irq_runtime_output
63AS
64SELECT
65  AndroidIrqRuntimeMetric(
66    'hw_irq',
67    (
68      SELECT
69        AndroidIrqRuntimeMetric_IrqRuntimeMetric(
70          'max_runtime',
71          max_runtime,
72          'total_count',
73          total_count,
74          'threshold_metric',
75          AndroidIrqRuntimeMetric_ThresholdMetric(
76            'threshold',
77            '1ms',
78            'over_threshold_count',
79            over_threshold_count,
80            'anomaly_ratio',
81            CAST(
82              over_threshold_count AS DOUBLE)
83            / CAST(
84              total_count AS DOUBLE)),
85          'longest_irq_slices',
86          (
87            SELECT
88              RepeatedField(
89                AndroidIrqRuntimeMetric_IrqSlice(
90                  'irq_name', name, 'ts', ts, 'dur', dur))
91            FROM (SELECT ts, dur, name FROM hw_irq_runtime LIMIT 10)
92          ))
93      FROM hw_irq_runtime_statistics
94    ),
95    'sw_irq',
96    (
97      SELECT
98        AndroidIrqRuntimeMetric_IrqRuntimeMetric(
99          'max_runtime',
100          max_runtime,
101          'total_count',
102          total_count,
103          'threshold_metric',
104          AndroidIrqRuntimeMetric_ThresholdMetric(
105            'threshold',
106            '5ms',
107            'over_threshold_count',
108            over_threshold_count,
109            'anomaly_ratio',
110            CAST(
111              over_threshold_count AS DOUBLE)
112            / CAST(
113              total_count AS DOUBLE)),
114          'longest_irq_slices',
115          (
116            SELECT
117              RepeatedField(
118                AndroidIrqRuntimeMetric_IrqSlice(
119                  'irq_name', name, 'ts', ts, 'dur', dur))
120            FROM (SELECT ts, dur, name FROM sw_irq_runtime LIMIT 10)
121          ))
122      FROM sw_irq_runtime_statistics
123    ));
124