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: 35. 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 optional Slice to_post_fork = 18; 90 optional Slice to_activity_thread_main = 19; 91 optional Slice to_bind_application = 20; 92 93 optional Slice time_post_fork = 16; 94 95 // The total time spent on opening dex files. 96 optional Slice time_dex_open = 24; 97 // Total time spent verifying classes during app startup. 98 optional Slice time_verify_class = 25; 99 100 // Number of methods that were compiled by JIT during app startup. 101 optional uint32 jit_compiled_methods = 27; 102 103 // Time spent running CPU on jit thread pool. 104 optional Slice time_jit_thread_pool_on_cpu = 28; 105 106 // Time spent on garbage collection. 107 optional Slice time_gc_total = 29; 108 optional Slice time_gc_on_cpu = 30; 109 110 // Time spent in lock contention on the main thread of the process being 111 // started up. This includes *all* types of lock contention not just monitor 112 // contention. 113 optional Slice time_lock_contention_thread_main = 31; 114 115 // Time spent in monitor lock contention on the main thread of the 116 // process being started up. This will be a subset of the time counted by 117 // |time_lock_contention_thread_main|. 118 optional Slice time_monitor_contention_thread_main = 32; 119 120 // Time spent in opening dex files on the main thread of the process 121 // being started up. 122 optional Slice time_dex_open_thread_main = 33; 123 124 // Time spent in dlopening .so files on the main thread of the process 125 // being started up. 126 optional Slice time_dlopen_thread_main = 34; 127 128 // Removed: was other_process_to_activity_cpu_ratio. 129 reserved 12; 130 131 // Removed: was uint32 versions of to_post_fork, to_activity_thread_main and 132 // to_bind_application. 133 reserved 13, 14, 15; 134 } 135 136 // Metrics about startup which were developed by looking at experiments using 137 // high-speed cameras (HSC). 138 message HscMetrics { 139 // The duration of the full "startup" as defined by HSC tests. 140 optional Slice full_startup = 1; 141 } 142 143 message Activity { 144 optional string name = 1; 145 optional string method = 2; 146 optional int64 ts_method_start = 4; 147 148 // Field 3 contained Slice with a sum of durations for matching slices. 149 reserved 3; 150 } 151 152 message BinderTransaction { 153 optional Slice duration = 1; 154 optional string thread = 2; 155 optional string destination_thread = 3; 156 optional string destination_process = 4; 157 // From 158 // https://cs.android.com/android/platform/superproject/+/master:external/perfetto/protos/perfetto/trace/ftrace/binder.proto;l=15;drc=7b6a788162a30802f4c9d8d7a30a54e25edd30f1 159 optional string flags = 5; 160 // From 161 // https://cs.android.com/android/platform/superproject/+/master:external/perfetto/protos/perfetto/trace/ftrace/binder.proto;l=14;drc=7b6a788162a30802f4c9d8d7a30a54e25edd30f1 162 optional string code = 6; 163 // From 164 // https://cs.android.com/android/platform/superproject/+/master:external/perfetto/protos/perfetto/trace/ftrace/binder.proto;l=37;drc=7b6a788162a30802f4c9d8d7a30a54e25edd30f1 165 optional int64 data_size = 7; 166 } 167 168 // Metrics with information about the status of odex files and the outcome 169 // of the loading process. 170 // Multiple files might be loaded for a single startup. Platform might also 171 // decide to discard an odex file and instead load a fallback, for example 172 // in case the OS or apk were updated. 173 message OptimizationStatus { 174 optional string odex_status = 1; 175 optional string compilation_filter = 2; 176 optional string compilation_reason = 3; 177 optional string location = 4; 178 } 179 180 // Contains the name and duration of class verification occurred during 181 // the startup. 182 message VerifyClass { 183 optional string name = 1; 184 optional int64 dur_ns = 2; 185 } 186 187 // Contains timestamps of important events which occurred during the 188 // startup. 189 message EventTimestamps { 190 optional int64 intent_received = 1; 191 optional int64 first_frame = 2; 192 } 193 194 // Contains information about the state of a system during the app startup. 195 // Useful to put the startup in context. 196 message SystemState { 197 // Whether the dex2oat64 process was running concurrent to the startup. 198 // Deprecated as of 10/2022. 199 optional bool dex2oat_running = 1 [deprecated=true]; 200 201 // Whether the installd process was running concurrent to the startup. 202 // Deprecated as of 10/2022. 203 optional bool installd_running = 2 [deprecated=true]; 204 205 // The number of broadcasts dispatched by the system during the app 206 // launch. 207 optional int64 broadcast_dispatched_count = 3; 208 209 // The number of broadcasts received by an app or the system during the 210 // app launch. Note that multiple packages can be subscribed to the same 211 // broadcast so a single dsipatch can cause multiple packages to receive 212 // and process a broadcast. 213 optional int64 broadcast_received_count = 4; 214 215 // The most active (i.e. consuming the most mcycles) processes during the 216 // app launch excluding the process(es) being launched. 217 // Note: the exact number of returned is an implementation detail and 218 // will likely change over time. 219 repeated string most_active_non_launch_processes = 5; 220 221 // Duration the installd process was running concurrent to the startup. 222 optional int64 installd_dur_ns = 6; 223 // Duration the dex2oat64 process was running concurrent to the startup. 224 optional int64 dex2oat_dur_ns = 7; 225 } 226 227 // Next id: 21 228 message Startup { 229 // Random id uniquely identifying an app startup in this trace. 230 optional uint32 startup_id = 1; 231 232 // Startup type (cold / warm / hot) 233 optional string startup_type = 16; 234 235 // Name of the package launched 236 optional string package_name = 2; 237 238 // Name of the process launched 239 optional string process_name = 3; 240 241 // Details about the activities launched 242 repeated Activity activities = 11; 243 244 // Details about slow binder transactions during the startup. The definition 245 // of a slow transaction is an implementation detail. 246 repeated BinderTransaction long_binder_transactions = 14; 247 248 // Did we ask the zygote for a new process 249 optional bool zygote_new_process = 4; 250 251 // Number of processes hosting the activity involved in the launch. 252 // This will usually be 1. If it is 0, it is indicative of a data / process 253 // error. If > 1, the process died during startup and the system respawned 254 // it. 255 optional uint32 activity_hosting_process_count = 6; 256 257 // Contains timestamps of important events which happened during 258 // the startup. 259 optional EventTimestamps event_timestamps = 13; 260 261 // Timing information spanning the intent received by the 262 // activity manager to the first frame drawn. 263 optional ToFirstFrame to_first_frame = 5; 264 265 // Details about the process (uid, version, etc) 266 optional AndroidProcessMetadata process = 7; 267 268 // Metrics about startup which were developed by looking at experiments 269 // using high-speed cameras (HSC). 270 optional HscMetrics hsc = 8; 271 272 // The time taken in the startup from intent received to the start time 273 // of the reportFullyDrawn slice. This should be longer than the time to 274 // first frame as the application decides this after it starts rendering. 275 optional Slice report_fully_drawn = 9; 276 277 // Contains information about the status of odex files. 278 repeated OptimizationStatus optimization_status = 12; 279 280 // Contains information about the class verification. 281 repeated VerifyClass verify_class = 19; 282 283 // Contains the dlopen file names. 284 repeated string dlopen_file = 20; 285 286 // Package name of startups running concurrent to the launch. 287 repeated string startup_concurrent_to_launch = 18; 288 289 // Contains information about the state of the rest of the system during the 290 // startup. This is useful for getting context about why a startup might 291 // be slow beyond just what the app is doing. 292 optional SystemState system_state = 15; 293 294 // A list of identified potential causes for slow startup. 295 // Optional. 296 repeated string slow_start_reason = 17; 297 298 reserved 10; 299 } 300 301 repeated Startup startup = 1; 302} 303