• 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
16INCLUDE PERFETTO MODULE android.startup.startup_events;
17
18-- Marks the beginning of the trace and is equivalent to when the statsd startup
19-- logging begins.
20CREATE PERFETTO VIEW _activity_intent_received AS
21SELECT
22  ts
23FROM slice
24WHERE
25  name = 'MetricsLogger:launchObserverNotifyIntentStarted';
26
27-- We partition the trace into spans based on posted activity intents.
28-- We will refine these progressively in the next steps to only encompass
29-- activity starts.
30CREATE PERFETTO TABLE _activity_intent_recv_spans AS
31SELECT
32  ts,
33  lead(ts, 1, trace_end()) OVER (ORDER BY ts) - ts AS dur
34FROM _activity_intent_received
35ORDER BY
36  ts;
37
38-- Filter activity_intent_recv_spans, keeping only the ones that triggered
39-- a startup.
40CREATE PERFETTO VIEW _startup_partitions AS
41SELECT
42  *
43FROM _activity_intent_recv_spans AS spans
44WHERE
45  1 = (
46    SELECT
47      count(1)
48    FROM _startup_events
49    WHERE
50      _startup_events.ts BETWEEN spans.ts AND spans.ts + spans.dur
51  );
52
53-- Successful activity startup. The end of the 'launching' event is not related
54-- to whether it actually succeeded or not.
55CREATE PERFETTO VIEW _activity_intent_startup_successful AS
56SELECT
57  ts
58FROM slice
59WHERE
60  name = 'MetricsLogger:launchObserverNotifyActivityLaunchFinished';
61
62-- Use the starting event package name. The finish event package name
63-- is not reliable in the case of failed startups.
64CREATE PERFETTO TABLE _startups_minsdk29 AS
65SELECT
66  lpart.ts,
67  le.ts_end,
68  le.ts_end - lpart.ts AS dur,
69  package_name AS package,
70  NULL AS startup_type
71FROM _startup_partitions AS lpart
72JOIN _startup_events AS le
73  ON (
74    le.ts BETWEEN lpart.ts AND lpart.ts + lpart.dur
75  )
76  AND (
77    le.ts_end BETWEEN lpart.ts AND lpart.ts + lpart.dur
78  )
79WHERE
80  (
81    SELECT
82      count(1)
83    FROM _activity_intent_startup_successful AS successful
84    WHERE
85      successful.ts BETWEEN lpart.ts AND lpart.ts + lpart.dur
86  ) > 0
87ORDER BY
88  lpart.ts;
89