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