1/* 2 * Copyright (C) 2018 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 21// Configuration for go/heapprofd. 22// Next id: 27 23message HeapprofdConfig { 24 message ContinuousDumpConfig { 25 // ms to wait before first dump. 26 optional uint32 dump_phase_ms = 5; 27 // ms to wait between following dumps. 28 optional uint32 dump_interval_ms = 6; 29 } 30 31 // Sampling rate for all heaps not specified via heap_sampling_intervals. 32 // 33 // These are: 34 // * All heaps if heap_sampling_intervals is empty. 35 // * Those profiled due to all_heaps and not named in heaps if 36 // heap_sampling_intervals is not empty. 37 // * The implicit libc.malloc heap if heaps is empty. 38 // 39 // Set to 1 for perfect accuracy. 40 // Otherwise, sample every sample_interval_bytes on average. 41 // 42 // See 43 // https://perfetto.dev/docs/data-sources/native-heap-profiler#sampling-interval 44 // for more details. 45 // 46 // BUGS 47 // Before Android 12, setting this to 0 would crash the target process. 48 optional uint64 sampling_interval_bytes = 1; 49 50 // If less than the given numbers of bytes are left free in the shared 51 // memory buffer, increase sampling interval by a factor of two. 52 // Adaptive sampling is disabled when set to 0. 53 optional uint64 adaptive_sampling_shmem_threshold = 24; 54 // Stop doubling the sampling_interval once the sampling interval has reached 55 // this value. 56 optional uint64 adaptive_sampling_max_sampling_interval_bytes = 25; 57 58 // E.g. surfaceflinger, com.android.phone 59 // This input is normalized in the following way: if it contains slashes, 60 // everything up to the last slash is discarded. If it contains "@", 61 // everything after the first @ is discared. 62 // E.g. /system/bin/surfaceflinger@1.0 normalizes to surfaceflinger. 63 // This transformation is also applied to the processes' command lines when 64 // matching. 65 repeated string process_cmdline = 2; 66 67 // For watermark based triggering or local debugging. 68 repeated uint64 pid = 4; 69 70 // Only profile target if it was installed by one of the packages given. 71 // Special values are: 72 // * @system: installed on the system partition 73 // * @product: installed on the product partition 74 // * @null: sideloaded 75 // Supported on Android 12+. 76 repeated string target_installed_by = 26; 77 78 // Which heaps to sample, e.g. "libc.malloc". If left empty, only samples 79 // "malloc". 80 // 81 // Introduced in Android 12. 82 repeated string heaps = 20; 83 84 // Which heaps not to sample, e.g. "libc.malloc". This is useful when used in 85 // combination with all_heaps; 86 // 87 // Introduced in Android 12. 88 repeated string exclude_heaps = 27; 89 90 optional bool stream_allocations = 23; 91 92 // If given, needs to be the same length as heaps and gives the sampling 93 // interval for the respective entry in heaps. 94 // 95 // Otherwise, sampling_interval_bytes is used. 96 // 97 // It is recommended to set sampling_interval_bytes to a reasonable default 98 // value when using this, as a value of 0 for sampling_interval_bytes will 99 // crash the target process before Android 12. 100 // 101 // Introduced in Android 12. 102 repeated uint64 heap_sampling_intervals = 22; 103 104 // Sample all heaps registered by target process. Introduced in Android 12. 105 optional bool all_heaps = 21; 106 107 // Profile all processes eligible for profiling on the system. 108 // See 109 // https://perfetto.dev/docs/data-sources/native-heap-profiler#heapprofd-targets 110 // for which processes are eligible. 111 // 112 // On unmodified userdebug builds, this will lead to system crashes. Zygote 113 // will crash when trying to launch a new process as it will have an 114 // unexpected open socket to heapprofd. 115 // 116 // heapprofd will likely be overloaded by the amount of data for low 117 // sampling intervals. 118 optional bool all = 5; 119 120 // Do not profile processes whose anon RSS + swap < given value. 121 // Introduced in Android 11. 122 optional uint32 min_anonymous_memory_kb = 15; 123 124 // Stop profile if heapprofd memory usage goes beyond the given value. 125 // Introduced in Android 11. 126 optional uint32 max_heapprofd_memory_kb = 16; 127 128 // Stop profile if heapprofd CPU time since start of this data-source 129 // goes beyond given value. 130 // Introduced in Android 11. 131 optional uint64 max_heapprofd_cpu_secs = 17; 132 133 // Do not emit function names for mappings starting with this prefix. 134 // E.g. /system to not emit symbols for any system libraries. 135 repeated string skip_symbol_prefix = 7; 136 137 // Dump at a predefined interval. 138 optional ContinuousDumpConfig continuous_dump_config = 6; 139 140 // Size of the shared memory buffer between the profiled processes and 141 // heapprofd. Defaults to 8 MiB. If larger than 500 MiB, truncated to 500 142 // MiB. 143 // 144 // Needs to be: 145 // * at least 8192, 146 // * a power of two, 147 // * a multiple of 4096. 148 optional uint64 shmem_size_bytes = 8; 149 150 // When the shmem buffer is full, block the client instead of ending the 151 // trace. Use with caution as this will significantly slow down the target 152 // process. 153 optional bool block_client = 9; 154 155 // If set, stop the trace session after blocking the client for this 156 // timeout. Needs to be larger than 100 us, otherwise no retries are done. 157 // Introduced in Android 11. 158 optional uint32 block_client_timeout_us = 14; 159 160 // Do not profile processes from startup, only match already running 161 // processes. 162 // 163 // Can not be set at the same time as no_running. 164 // Introduced in Android 11. 165 optional bool no_startup = 10; 166 167 // Do not profile running processes. Only match processes on startup. 168 // 169 // Can not be set at the same time as no_startup. 170 // Introduced in Android 11. 171 optional bool no_running = 11; 172 173 // deprecated idle_allocations. 174 reserved 12; 175 176 // Cause heapprofd to emit a single dump at the end, showing the memory usage 177 // at the point in time when the sampled heap usage of the process was at its 178 // maximum. This causes ProfilePacket.HeapSample.self_max to be set, and 179 // self_allocated and self_freed to not be set. 180 // Introduced in Android 11. 181 optional bool dump_at_max = 13; 182 183 // FEATURE FLAGS. THERE BE DRAGONS. 184 185 // Escape hatch if the session is being torn down because of a forked child 186 // that shares memory space, but is not correctly identified as a vforked 187 // child. 188 // Introduced in Android 11. 189 optional bool disable_fork_teardown = 18; 190 191 // We try to automatically detect when a target applicatation vforks but then 192 // does a memory allocation (or free). This auto-detection can be disabled 193 // with this. 194 // Introduced in Android 11. 195 optional bool disable_vfork_detection = 19; 196} 197