xref: /aosp_15_r20/external/perfetto/protos/perfetto/metrics/android/startup_metric.proto (revision 6dbdd20afdafa5e3ca9b8809fa73465d530080dc)
1/*
2 * Copyright (C) 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 *      http://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
17syntax = "proto2";
18
19package perfetto.protos;
20
21import "protos/perfetto/metrics/android/process_metadata.proto";
22
23// Android app startup metrics.
24message AndroidStartupMetric {
25  // A simplified view of the task state durations for a thread
26  // and a span of time.
27  message TaskStateBreakdown {
28    optional int64 running_dur_ns = 1;
29    optional int64 runnable_dur_ns = 2;
30    optional int64 uninterruptible_sleep_dur_ns = 3;
31    optional int64 interruptible_sleep_dur_ns = 4;
32    optional int64 uninterruptible_io_sleep_dur_ns = 5;
33    optional int64 uninterruptible_non_io_sleep_dur_ns = 6;
34  }
35
36  message McyclesByCoreType {
37    optional int64 little = 1;
38    optional int64 big = 2;
39    optional int64 bigger = 3;
40    optional int64 unknown = 4;
41  }
42
43  message Slice {
44    optional int64 dur_ns = 1;
45    optional double dur_ms = 2;
46  }
47
48  // Timing information spanning the intent received by the
49  // activity manager to the first frame drawn.
50  // Next id: 38
51  message ToFirstFrame {
52    // The duration between the intent received and first frame.
53    optional int64 dur_ns = 1;
54    optional double dur_ms = 17;
55
56    // Breakdown of time to first frame by task state for the main thread of
57    // the process starting up.
58    optional TaskStateBreakdown main_thread_by_task_state = 2;
59
60    // The mcycles taken by this startup across all CPUs (broken down by core
61    // type).
62    optional McyclesByCoreType mcycles_by_core_type = 26;
63
64    // In this timespan, how many processes (apart from the main activity) were
65    // spawned.
66    optional uint32 other_processes_spawned_count = 3;
67
68    // Total time spent in activity manager between the initial intent
69    // and the end of the activity starter.
70    optional Slice time_activity_manager = 4;
71
72    // The following slices follow the typical steps post-fork.
73    optional Slice time_activity_thread_main = 5;
74    optional Slice time_bind_application = 6;
75    optional Slice time_activity_start = 7;
76    optional Slice time_activity_resume = 8;
77    optional Slice time_activity_restart = 21;
78    optional Slice time_choreographer = 9;
79    optional Slice time_inflate = 22;
80    optional Slice time_get_resources = 23;
81
82    // If we are starting a new process, record the duration from the
83    // intent being received to the time we call the zygote.
84    optional Slice time_before_start_process = 10;
85
86    // The actual duration of the process start (based on the zygote slice).
87    optional Slice time_during_start_process = 11;
88
89    // The duration from launch to first running state thread of startup
90    // process.
91    optional Slice time_to_running_state = 35;
92
93    optional Slice to_post_fork = 18;
94    optional Slice to_activity_thread_main = 19;
95    optional Slice to_bind_application = 20;
96
97    optional Slice time_post_fork = 16;
98
99    // Total time on class initialization during app startup.
100    optional Slice time_class_initialization = 36;
101    // The total time spent on opening dex files.
102    optional Slice time_dex_open = 24;
103    // Total time spent verifying classes during app startup.
104    optional Slice time_verify_class = 25;
105
106    // Number of methods that were compiled by JIT during app startup.
107    optional uint32 jit_compiled_methods = 27;
108
109    // Number of class initializations during app startup.
110    optional uint32 class_initialization_count = 37;
111
112    // Time spent running CPU on jit thread pool.
113    optional Slice time_jit_thread_pool_on_cpu = 28;
114
115    // Time spent on garbage collection.
116    optional Slice time_gc_total = 29;
117    optional Slice time_gc_on_cpu = 30;
118
119    // Time spent in lock contention on the main thread of the process being
120    // started up. This includes *all* types of lock contention not just monitor
121    // contention.
122    optional Slice time_lock_contention_thread_main = 31;
123
124    // Time spent in monitor lock contention on the main thread of the
125    // process being started up. This will be a subset of the time counted by
126    // |time_lock_contention_thread_main|.
127    optional Slice time_monitor_contention_thread_main = 32;
128
129    // Time spent in opening dex files on the main thread of the process
130    // being started up.
131    optional Slice time_dex_open_thread_main = 33;
132
133    // Time spent in dlopening .so files on the main thread of the process
134    // being started up.
135    optional Slice time_dlopen_thread_main = 34;
136
137    // Removed: was other_process_to_activity_cpu_ratio.
138    reserved 12;
139
140    // Removed: was uint32 versions of to_post_fork, to_activity_thread_main and
141    // to_bind_application.
142    reserved 13, 14, 15;
143  }
144
145  // Metrics about startup which were developed by looking at experiments using
146  // high-speed cameras (HSC).
147  message HscMetrics {
148    // The duration of the full "startup" as defined by HSC tests.
149    optional Slice full_startup = 1;
150  }
151
152  message Activity {
153    optional string name = 1;
154    optional string method = 2;
155    optional int64 ts_method_start = 4;
156
157    // Field 3 contained Slice with a sum of durations for matching slices.
158    reserved 3;
159  }
160
161  message BinderTransaction {
162    optional Slice duration = 1;
163    optional string thread = 2;
164    optional string destination_thread = 3;
165    optional string destination_process = 4;
166    // From
167    // https://cs.android.com/android/platform/superproject/main/+/main:external/perfetto/protos/perfetto/trace/ftrace/binder.proto;l=15;drc=7b6a788162a30802f4c9d8d7a30a54e25edd30f1
168    optional string flags = 5;
169    // From
170    // https://cs.android.com/android/platform/superproject/main/+/main:external/perfetto/protos/perfetto/trace/ftrace/binder.proto;l=14;drc=7b6a788162a30802f4c9d8d7a30a54e25edd30f1
171    optional string code = 6;
172    // From
173    // https://cs.android.com/android/platform/superproject/main/+/main:external/perfetto/protos/perfetto/trace/ftrace/binder.proto;l=37;drc=7b6a788162a30802f4c9d8d7a30a54e25edd30f1
174    optional int64 data_size = 7;
175  }
176
177  // Metrics with information about the status of odex files and the outcome
178  // of the loading process.
179  // Multiple files might be loaded for a single startup. Platform might also
180  // decide to discard an odex file and instead load a fallback, for example
181  // in case the OS or apk were updated.
182  message OptimizationStatus {
183    optional string odex_status = 1;
184    optional string compilation_filter = 2;
185    optional string compilation_reason = 3;
186    optional string location = 4;
187    optional string summary = 5;
188  }
189
190  // Contains the name and duration of class verification occurred during
191  // the startup.
192  message VerifyClass {
193    optional string name = 1;
194    optional int64 dur_ns = 2;
195  }
196
197  // Contains timestamps of important events which occurred during the
198  // startup.
199  message EventTimestamps {
200    optional int64 intent_received = 1;
201    optional int64 first_frame = 2;
202  }
203
204  // Contains information about the state of a system during the app startup.
205  // Useful to put the startup in context.
206  message SystemState {
207    // Whether the dex2oat64 process was running concurrent to the startup.
208    // Deprecated as of 10/2022.
209    optional bool dex2oat_running = 1 [deprecated = true];
210
211    // Whether the installd process was running concurrent to the startup.
212    // Deprecated as of 10/2022.
213    optional bool installd_running = 2 [deprecated = true];
214
215    // The number of broadcasts dispatched by the system during the app
216    // launch.
217    optional int64 broadcast_dispatched_count = 3;
218
219    // The number of broadcasts received by an app or the system during the
220    // app launch. Note that multiple packages can be subscribed to the same
221    // broadcast so a single dsipatch can cause multiple packages to receive
222    // and process a broadcast.
223    optional int64 broadcast_received_count = 4;
224
225    // The most active (i.e. consuming the most mcycles) processes during the
226    // app launch excluding the process(es) being launched.
227    // Note: the exact number of returned is an implementation detail and
228    // will likely change over time.
229    repeated string most_active_non_launch_processes = 5;
230
231    // Duration the installd process was running concurrent to the startup.
232    optional int64 installd_dur_ns = 6;
233    // Duration the dex2oat64 process was running concurrent to the startup.
234    optional int64 dex2oat_dur_ns = 7;
235  }
236
237  // Contains detailed information for slow startup causes.
238  message SlowStartReasonDetailed {
239    optional string reason = 1;
240    optional string details = 2;
241  }
242
243  // Contains information for slow startup causes.
244  // Next id: 11.
245  message SlowStartReason {
246    // Points to reason description and solution.
247    enum ReasonId {
248      REASON_ID_UNSPECIFIED = 0;
249      NO_BASELINE_OR_CLOUD_PROFILES = 1;
250      RUN_FROM_APK = 2;
251      UNLOCK_RUNNING = 3;
252      APP_IN_DEBUGGABLE_MODE = 4;
253      GC_ACTIVITY = 5;
254      DEX2OAT_RUNNING = 6;
255      INSTALLD_RUNNING = 7;
256      MAIN_THREAD_TIME_SPENT_IN_RUNNABLE = 8;
257      MAIN_THREAD_TIME_SPENT_IN_INTERRUPTIBLE_SLEEP = 9;
258      MAIN_THREAD_TIME_SPENT_IN_BLOCKING_IO = 10;
259      MAIN_THREAD_TIME_SPENT_IN_OPEN_DEX_FILES_FROM_OAT = 11;
260      TIME_SPENT_IN_BIND_APPLICATION = 12;
261      TIME_SPENT_IN_VIEW_INFLATION = 13;
262      TIME_SPENT_IN_RESOURCES_MANAGER_GET_RESOURCES = 14;
263      TIME_SPENT_VERIFYING_CLASSES = 15;
264      POTENTIAL_CPU_CONTENTION_WITH_ANOTHER_PROCESS = 16;
265      JIT_ACTIVITY = 17;
266      MAIN_THREAD_LOCK_CONTENTION = 18;
267      MAIN_THREAD_MONITOR_CONTENTION = 19;
268      JIT_COMPILED_METHODS = 20;
269      BROADCAST_DISPATCHED_COUNT = 21;
270      BROADCAST_RECEIVED_COUNT = 22;
271      STARTUP_RUNNING_CONCURRENT = 23;
272      MAIN_THREAD_BINDER_TRANSCATIONS_BLOCKED = 24;
273    }
274    optional ReasonId reason_id = 1;
275
276    // Brief description for human readability.
277    optional string reason = 2;
278
279    // Severity level for a reason.
280    enum SeverityLevel {
281      SEVERITY_UNSPECIFIED = 0;
282      ERROR = 1;
283      WARNING = 2;
284      INFO = 3;
285    }
286    optional SeverityLevel severity = 10;
287
288    // Expected value (inherited from threshold definition).
289    optional ThresholdValue expected_value = 3;
290
291    // Actual value, can be used to decide severity level.
292    optional ActualValue actual_value = 4;
293
294    // Launch duration
295    optional int64 launch_dur = 5;
296
297    // Sum of durations of slices and thread states in trace_slices_or_threads.
298    // Can be used to decide if a couple of top slices or threads caused the
299    // issue.
300    optional int64 duration = 6;
301
302    // Information of a subset of slice and thread sections to focused on,
303    // sorted by the duration in descending order.
304    // By checking out the top slices/threads, developers can identify specific
305    // slices or threads for further investigation.
306    optional TraceSliceSectionInfo trace_slice_sections = 7;
307    optional TraceThreadSectionInfo trace_thread_sections = 8;
308
309    // Details specific for a reason.
310    optional string additional_info = 9;
311  }
312
313  message ThresholdValue {
314    // Expected value. 1 for true and 0 for false for booleans.
315    optional int64 value = 1;
316
317    // Expected value unit. Enum, e.g. "ns", "%"
318    enum ThresholdUnit {
319      THRESHOLD_UNIT_UNSPECIFIED = 0;
320      NS = 1;
321      PERCENTAGE = 2;
322      TRUE_OR_FALSE = 3;
323      COUNT = 4;
324    }
325    optional ThresholdUnit unit = 2;
326
327    // For numeric threshold values only. When higher_expected is true,
328    // an app startup is considered performant if actual value is higher
329    // than the threshold.
330    optional bool higher_expected = 3;
331  }
332
333  message ActualValue {
334    // Actual value. 1 for true and 0 for false for booleans.
335    optional int64 value = 1;
336
337    // Actual duration for percentage thresholds only.
338    // E.g. if the threashold is 20% and the launch_duration is 1000ms,
339    // then the actual duration is more than 200ms.
340    optional int64 dur = 2;
341  }
342
343  // Contains information for a section of a slice.
344  message TraceSliceSection {
345    optional int64 start_timestamp = 1;
346
347    optional int64 end_timestamp = 2;
348
349    optional uint32 slice_id = 3;
350
351    optional string slice_name = 4;
352
353    optional uint32 process_pid = 5;
354
355    optional uint32 thread_tid = 6;
356  }
357
358  // Information for the SliceSections
359  message TraceSliceSectionInfo {
360    repeated TraceSliceSection slice_section = 1;
361    optional int64 start_timestamp = 2;
362    optional int64 end_timestamp = 3;
363  }
364
365  // Contains information for a section of a thread.
366  message TraceThreadSection {
367    optional int64 start_timestamp = 1;
368
369    optional int64 end_timestamp = 2;
370
371    // Deprecated as of 09/2024
372    optional uint32 thread_utid = 3;
373
374    optional string thread_name = 4;
375
376    optional uint32 process_pid = 5;
377
378    optional uint32 thread_tid = 6;
379  }
380
381  // Information for the ThreadSections
382  message TraceThreadSectionInfo {
383    repeated TraceThreadSection thread_section = 1;
384    optional int64 start_timestamp  = 2;
385    optional int64 end_timestamp = 3;
386  }
387
388  // Next id: 26
389  message Startup {
390    // Random id uniquely identifying an app startup in this trace.
391    optional uint32 startup_id = 1;
392
393    // Startup type (cold / warm / hot)
394    optional string startup_type = 16;
395
396    // Number of CPUs the device has
397    optional uint32 cpu_count = 25;
398
399    // Name of the package launched
400    optional string package_name = 2;
401
402    // Name of the process launched
403    optional string process_name = 3;
404
405    // Details about the activities launched
406    repeated Activity activities = 11;
407
408    // Details about slow binder transactions during the startup. The definition
409    // of a slow transaction is an implementation detail.
410    repeated BinderTransaction long_binder_transactions = 14;
411
412    // Did we ask the zygote for a new process
413    optional bool zygote_new_process = 4;
414
415    // Number of processes hosting the activity involved in the launch.
416    // This will usually be 1. If it is 0, it is indicative of a data / process
417    // error. If > 1, the process died during startup and the system respawned
418    // it.
419    optional uint32 activity_hosting_process_count = 6;
420
421    // Time it takes to display the first frame of the app`s UI.
422    // Details:
423    // https://developer.android.com/topic/performance/vitals/launch-time#time-initial
424    optional int64 time_to_initial_display = 22;
425
426    // Time to full display (TTFD) is the time ittakes for an app to become
427    // interactive for the user.
428    // Datails:
429    // https://developer.android.com/topic/performance/vitals/launch-time#time-full
430    optional int64 time_to_full_display = 23;
431
432    // Contains timestamps of important events which happened during
433    // the startup.
434    optional EventTimestamps event_timestamps = 13;
435
436    // Timing information spanning the intent received by the
437    // activity manager to the first frame drawn.
438    optional ToFirstFrame to_first_frame = 5;
439
440    // Details about the process (uid, version, etc)
441    optional AndroidProcessMetadata process = 7;
442
443    // Metrics about startup which were developed by looking at experiments
444    // using high-speed cameras (HSC).
445    optional HscMetrics hsc = 8;
446
447    // The time taken in the startup from intent received to the start time
448    // of the reportFullyDrawn slice. This should be longer than the time to
449    // first frame as the application decides this after it starts rendering.
450    optional Slice report_fully_drawn = 9;
451
452    // Contains information about the status of odex files.
453    repeated OptimizationStatus optimization_status = 12;
454
455    // Contains information about the class verification.
456    repeated VerifyClass verify_class = 19;
457
458    // Contains the dlopen file names.
459    repeated string dlopen_file = 20;
460
461    // Package name of startups running concurrent to the launch.
462    repeated string startup_concurrent_to_launch = 18;
463
464    // Contains information about the state of the rest of the system during the
465    // startup. This is useful for getting context about why a startup might
466    // be slow beyond just what the app is doing.
467    optional SystemState system_state = 15;
468
469    // A list of identified potential causes for slow startup.
470    // Optional.
471    repeated string slow_start_reason = 17;
472
473    // Same as slow_start_reason, but with more detailed information, obsolete.
474    repeated SlowStartReasonDetailed slow_start_reason_detailed = 21;
475
476    // Similar to slow_start_reason_detailed, but with much more comprehensive
477    // info. such as expected threshold, actual value and threads/slices to
478    // inspect. slow_start_reason will be obsolete once
479    // slow_start_reason_with_details is completed since
480    // slow_start_reason_with_details contains all the data in slow_start_reason
481    // and more.
482    repeated SlowStartReason slow_start_reason_with_details = 24;
483
484    reserved 10;
485  }
486
487  repeated Startup startup = 1;
488}
489