• 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-- Marks the beginning of the trace and is equivalent to when the statsd startup
17-- logging begins.
18CREATE VIEW internal_activity_intent_received AS
19SELECT ts FROM slice
20WHERE name = 'MetricsLogger:launchObserverNotifyIntentStarted';
21
22-- We partition the trace into spans based on posted activity intents.
23-- We will refine these progressively in the next steps to only encompass
24-- activity starts.
25CREATE TABLE internal_activity_intent_recv_spans AS
26SELECT
27  ROW_NUMBER()
28  OVER(ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS startup_id,
29  ts,
30  LEAD(ts, 1, (SELECT end_ts FROM trace_bounds)) OVER(ORDER BY ts) - ts AS dur
31FROM internal_activity_intent_received
32ORDER BY ts;
33
34-- Filter activity_intent_recv_spans, keeping only the ones that triggered
35-- a startup.
36CREATE VIEW internal_startup_partitions AS
37SELECT * FROM internal_activity_intent_recv_spans AS spans
38WHERE 1 = (
39  SELECT COUNT(1)
40  FROM internal_startup_events
41  WHERE internal_startup_events.ts BETWEEN spans.ts AND spans.ts + spans.dur);
42
43-- Successful activity startup. The end of the 'launching' event is not related
44-- to whether it actually succeeded or not.
45CREATE VIEW internal_activity_intent_startup_successful AS
46SELECT ts FROM slice
47WHERE name = 'MetricsLogger:launchObserverNotifyActivityLaunchFinished';
48
49-- Use the starting event package name. The finish event package name
50-- is not reliable in the case of failed startups.
51INSERT INTO internal_all_startups
52SELECT
53  "minsdk29",
54  lpart.startup_id,
55  lpart.ts,
56  le.ts_end,
57  le.ts_end - lpart.ts AS dur,
58  package_name AS package,
59  NULL AS startup_type
60FROM internal_startup_partitions AS lpart
61JOIN internal_startup_events le ON
62  (le.ts BETWEEN lpart.ts AND lpart.ts + lpart.dur)
63  AND (le.ts_end BETWEEN lpart.ts AND lpart.ts + lpart.dur)
64WHERE (
65  SELECT COUNT(1)
66  FROM internal_activity_intent_startup_successful AS successful
67  WHERE successful.ts BETWEEN lpart.ts AND lpart.ts + lpart.dur
68) > 0;
69