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 } 33 34 message McyclesByCoreType { 35 optional int64 little = 1; 36 optional int64 big = 2; 37 optional int64 bigger = 3; 38 optional int64 unknown = 4; 39 } 40 41 message Slice { 42 optional int64 dur_ns = 1; 43 optional double dur_ms = 2; 44 } 45 46 // Timing information spanning the intent received by the 47 // activity manager to the first frame drawn. 48 // Next id: 31. 49 message ToFirstFrame { 50 // The duration between the intent received and first frame. 51 optional int64 dur_ns = 1; 52 optional double dur_ms = 17; 53 54 // Breakdown of time to first frame by task state for the main thread of 55 // the process starting up. 56 optional TaskStateBreakdown main_thread_by_task_state = 2; 57 58 // The mcycles taken by this startup across all CPUs (broken down by core 59 // type). 60 optional McyclesByCoreType mcycles_by_core_type = 26; 61 62 // In this timespan, how many processes (apart from the main activity) were 63 // spawned. 64 optional uint32 other_processes_spawned_count = 3; 65 66 // Total time spent in activity manager between the initial intent 67 // and the end of the activity starter. 68 optional Slice time_activity_manager = 4; 69 70 // The following slices follow the typical steps post-fork. 71 optional Slice time_activity_thread_main = 5; 72 optional Slice time_bind_application = 6; 73 optional Slice time_activity_start = 7; 74 optional Slice time_activity_resume = 8; 75 optional Slice time_activity_restart = 21; 76 optional Slice time_choreographer = 9; 77 optional Slice time_inflate = 22; 78 optional Slice time_get_resources = 23; 79 80 // If we are starting a new process, record the duration from the 81 // intent being received to the time we call the zygote. 82 optional Slice time_before_start_process = 10; 83 84 // The actual duration of the process start (based on the zygote slice). 85 optional Slice time_during_start_process = 11; 86 87 optional Slice to_post_fork = 18; 88 optional Slice to_activity_thread_main = 19; 89 optional Slice to_bind_application = 20; 90 91 optional Slice time_post_fork = 16; 92 93 // The total time spent on opening dex files. 94 optional Slice time_dex_open = 24; 95 // Total time spent verifying classes during app startup. 96 optional Slice time_verify_class = 25; 97 98 // Number of methods that were compiled by JIT during app startup. 99 optional uint32 jit_compiled_methods = 27; 100 101 // Time spent running CPU on jit thread pool. 102 optional Slice time_jit_thread_pool_on_cpu = 28; 103 104 // Time spent on garbage collection. 105 optional Slice time_gc_total = 29; 106 optional Slice time_gc_on_cpu = 30; 107 // Deprecated was other_process_to_activity_cpu_ratio 108 reserved 12; 109 110 // Removed: was uint32 versions of to_post_fork, to_activity_thread_main and 111 // to_bind_application. 112 reserved 13, 14, 15; 113 } 114 115 // Metrics about startup which were developed by looking at experiments using 116 // high-speed cameras (HSC). 117 message HscMetrics { 118 // The duration of the full "startup" as defined by HSC tests. 119 optional Slice full_startup = 1; 120 } 121 122 message Activity { 123 optional string name = 1; 124 optional string method = 2; 125 optional int64 ts_method_start = 4; 126 127 // Field 3 contained Slice with a sum of durations for matching slices. 128 reserved 3; 129 } 130 131 message BinderTransaction { 132 optional Slice duration = 1; 133 optional string thread = 2; 134 } 135 136 // Metrics with information about the status of odex files and the outcome 137 // of the loading process. 138 // Multiple files might be loaded for a single startup. Platform might also 139 // decide to discard an odex file and instead load a fallback, for example 140 // in case the OS or apk were updated. 141 message OptimizationStatus { 142 optional string odex_status = 1; 143 optional string compilation_filter = 2; 144 optional string compilation_reason = 3; 145 optional string location = 4; 146 } 147 148 // Contains timestamps of important events which occurred during the 149 // startup. 150 message EventTimestamps { 151 optional int64 intent_received = 1; 152 optional int64 first_frame = 2; 153 } 154 155 // Next id: 15 156 message Startup { 157 // Random id uniquely identifying an app startup in this trace. 158 optional uint32 startup_id = 1; 159 160 // Name of the package launched 161 optional string package_name = 2; 162 163 // Name of the process launched 164 optional string process_name = 3; 165 166 // Details about the activities launched 167 repeated Activity activities = 11; 168 169 // Details about slow binder transactions during the startup. The definition 170 // of a slow transaction is an implementation detail. 171 repeated BinderTransaction long_binder_transactions = 14; 172 173 // Did we ask the zygote for a new process 174 optional bool zygote_new_process = 4; 175 176 // Number of processes hosting the activity involved in the launch. 177 // This will usually be 1. If it is 0, it is indicative of a data / process 178 // error. If > 1, the process died during startup and the system respawned 179 // it. 180 optional uint32 activity_hosting_process_count = 6; 181 182 // Contains timestamps of important events which happened during 183 // the startup. 184 optional EventTimestamps event_timestamps = 13; 185 186 // Timing information spanning the intent received by the 187 // activity manager to the first frame drawn. 188 optional ToFirstFrame to_first_frame = 5; 189 190 // Details about the process (uid, version, etc) 191 optional AndroidProcessMetadata process = 7; 192 193 // Metrics about startup which were developed by looking at experiments 194 // using high-speed cameras (HSC). 195 optional HscMetrics hsc = 8; 196 197 // The time taken in the startup from intent recieved to the start time 198 // of the reportFullyDrawn slice. This should be longer than the time to 199 // first frame as the application decides this after it starts rendering. 200 optional Slice report_fully_drawn = 9; 201 202 // Conntains information about the status of odex files. 203 repeated OptimizationStatus optimization_status = 12; 204 205 reserved 10; 206 } 207 208 repeated Startup startup = 1; 209} 210