1# Copyright (C) 2023 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# proto-message: TraceConfig
16
17# Enable periodic flushing of the trace buffer into the output file.
18write_into_file: true
19
20# Writes the userspace buffer into the file every 1s.
21file_write_period_ms: 1000
22
23# See b/126487238 - we need to guarantee ordering of events.
24flush_period_ms: 10000
25
26# The trace buffers needs to be big enough to hold |file_write_period_ms| of
27# trace data. The trace buffer sizing depends on the number of trace categories
28# enabled and the device activity.
29
30# RSS events
31buffers {
32  size_kb: 32768
33  fill_policy: RING_BUFFER
34}
35
36# procfs polling and linux system info from sysfs
37buffers {
38  size_kb: 8192
39  fill_policy: RING_BUFFER
40}
41
42# heapprofd memory
43buffers {
44  size_kb: 32768
45  fill_policy: RING_BUFFER
46}
47
48# java hprof memory
49buffers {
50  size_kb: 65536
51  fill_policy: RING_BUFFER
52}
53
54data_sources {
55  config {
56    name: "linux.ftrace"
57    target_buffer: 0
58    ftrace_config {
59      throttle_rss_stat: true
60      # These parameters affect only the kernel trace buffer size and how
61      # frequently it gets moved into the userspace buffer defined above.
62      buffer_size_kb: 16384
63      drain_period_ms: 250
64
65      # Store certain high-volume "sched" ftrace events in a denser format
66      # (falling back to the default format if not supported by the tracer).
67      compact_sched {
68        enabled: true
69      }
70
71      # Enables symbol name resolution against /proc/kallsyms
72      symbolize_ksyms: true
73      # Parse kallsyms before acknowledging that the ftrace data source has been started. In
74      # combination with "perfetto --background-wait" as the consumer, it lets us defer the
75      # test we're tracing until after the cpu has quieted down from the cpu-bound kallsyms parsing.
76      initialize_ksyms_synchronously_for_testing: true
77      # Avoid re-parsing kallsyms on every test run, as it takes 200-500ms per run. See b/239951079
78      ksyms_mem_policy: KSYMS_RETAIN
79
80      # We need to do process tracking to ensure kernel ftrace events targeted at short-lived
81      # threads are associated correctly
82      ftrace_events: "task/task_newtask"
83      ftrace_events: "task/task_rename"
84      ftrace_events: "sched/sched_process_exit"
85      ftrace_events: "sched/sched_process_free"
86
87      # Memory events
88      ftrace_events: "rss_stat"
89      ftrace_events: "ion_heap_shrink"
90      ftrace_events: "ion_heap_grow"
91      ftrace_events: "ion/ion_stat"
92      ftrace_events: "dmabuf_heap/dma_heap_stat"
93      ftrace_events: "oom_score_adj_update"
94      ftrace_events: "gpu_mem/gpu_mem_total"
95      ftrace_events: "fastrpc/fastrpc_dma_stat"
96
97      # Power events
98      ftrace_events: "power/suspend_resume"
99      ftrace_events: "power/cpu_frequency"
100      ftrace_events: "power/cpu_idle"
101      ftrace_events: "power/gpu_frequency"
102
103      # Old (kernel) LMK
104      ftrace_events: "lowmemorykiller/lowmemory_kill"
105
106      atrace_apps: "*"
107
108      atrace_categories: "am"
109      atrace_categories: "aidl"
110      atrace_categories: "bionic"
111      atrace_categories: "camera"
112      atrace_categories: "wm"
113      atrace_categories: "dalvik"
114      atrace_categories: "sched"
115      atrace_categories: "freq"
116      atrace_categories: "gfx"
117      atrace_categories: "view"
118      atrace_categories: "webview"
119      atrace_categories: "input"
120      atrace_categories: "hal"
121      atrace_categories: "binder_driver"
122      atrace_categories: "sync"
123      atrace_categories: "workq"
124      atrace_categories: "res"
125      atrace_categories: "power"
126
127    }
128  }
129}
130
131data_sources: {
132  config {
133    name: "android.gpu.memory"
134    target_buffer: 0
135  }
136}
137
138data_sources {
139  config {
140    name: "linux.process_stats"
141    target_buffer: 1
142    process_stats_config {
143      proc_stats_poll_ms: 10000
144    }
145  }
146}
147
148data_sources {
149  config {
150    name: "linux.system_info"
151    target_buffer: 1
152  }
153}
154
155data_sources {
156  config {
157    name: "linux.sys_stats"
158    target_buffer: 1
159    sys_stats_config {
160      meminfo_period_ms: 1000
161      meminfo_counters: MEMINFO_MEM_TOTAL
162      meminfo_counters: MEMINFO_MEM_FREE
163      meminfo_counters: MEMINFO_MEM_AVAILABLE
164      meminfo_counters: MEMINFO_BUFFERS
165      meminfo_counters: MEMINFO_CACHED
166      meminfo_counters: MEMINFO_SWAP_CACHED
167      meminfo_counters: MEMINFO_ACTIVE
168      meminfo_counters: MEMINFO_INACTIVE
169      meminfo_counters: MEMINFO_ACTIVE_ANON
170      meminfo_counters: MEMINFO_INACTIVE_ANON
171      meminfo_counters: MEMINFO_ACTIVE_FILE
172      meminfo_counters: MEMINFO_INACTIVE_FILE
173      meminfo_counters: MEMINFO_UNEVICTABLE
174      meminfo_counters: MEMINFO_SWAP_TOTAL
175      meminfo_counters: MEMINFO_SWAP_FREE
176      meminfo_counters: MEMINFO_DIRTY
177      meminfo_counters: MEMINFO_WRITEBACK
178      meminfo_counters: MEMINFO_ANON_PAGES
179      meminfo_counters: MEMINFO_MAPPED
180      meminfo_counters: MEMINFO_SHMEM
181    }
182  }
183}
184
185data_sources {
186  config {
187    name: "android.heapprofd"
188    target_buffer: 2
189    heapprofd_config {
190      sampling_interval_bytes: 16384
191      process_cmdline: "system_server"
192      process_cmdline: "com.android.systemui"
193      process_cmdline: "com.google.android.apps.nexuslauncher"
194      process_cmdline: "/system/bin/surfaceflinger"
195      no_startup: true
196      shmem_size_bytes: 16777216
197    }
198  }
199}
200
201data_sources {
202  config {
203    name: "android.java_hprof"
204    target_buffer: 3
205    java_hprof_config {
206      process_cmdline: "system_server"
207      process_cmdline: "com.android.systemui"
208      process_cmdline: "com.google.android.apps.nexuslauncher"
209    }
210  }
211}
212
213data_sources: {
214  config: {
215    name: "android.surfaceflinger.frametimeline"
216  }
217}
218
219data_sources: {
220  config {
221    name: "android.power"
222    target_buffer: 1
223    android_power_config {
224      battery_poll_ms: 1000
225      collect_power_rails: true
226      battery_counters: BATTERY_COUNTER_CAPACITY_PERCENT
227      battery_counters: BATTERY_COUNTER_CHARGE
228      battery_counters: BATTERY_COUNTER_CURRENT
229    }
230  }
231}
232