• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2022 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"""Contains tables for tracks."""
15
16from python.generators.trace_processor_table.public import Column as C
17from python.generators.trace_processor_table.public import CppInt32
18from python.generators.trace_processor_table.public import CppInt64
19from python.generators.trace_processor_table.public import CppOptional
20from python.generators.trace_processor_table.public import CppString
21from python.generators.trace_processor_table.public import Table
22from python.generators.trace_processor_table.public import TableDoc
23from python.generators.trace_processor_table.public import ColumnDoc
24from python.generators.trace_processor_table.public import CppSelfTableId
25from python.generators.trace_processor_table.public import CppTableId
26from python.generators.trace_processor_table.public import CppUint32
27
28from src.trace_processor.tables.metadata_tables import MACHINE_TABLE
29
30TRACK_TABLE = Table(
31    python_module=__file__,
32    class_name="TrackTable",
33    sql_name="track",
34    columns=[
35        C("name", CppString()),
36        C("parent_id", CppOptional(CppSelfTableId())),
37        C("source_arg_set_id", CppOptional(CppUint32())),
38        C('machine_id', CppOptional(CppTableId(MACHINE_TABLE))),
39    ],
40    tabledoc=TableDoc(
41        doc='''
42          Tracks are a fundamental concept in trace processor and represent a
43          "timeline" for events of the same type and with the same context. See
44          https://perfetto.dev/docs/analysis/trace-processor#tracks for a more
45          detailed explanation, with examples.
46        ''',
47        group='Tracks',
48        columns={
49            'name':
50                '''
51                  Name of the track; can be null for some types of tracks (e.g.
52                  thread tracks).
53                ''',
54            'parent_id':
55                '''
56                  The track which is the "parent" of this track. Only non-null
57                  for tracks created using Perfetto's track_event API.
58                ''',
59            'source_arg_set_id':
60                ColumnDoc(
61                    doc='''
62                      Args for this track which store information about "source"
63                      of this track in the trace. For example: whether this
64                      track orginated from atrace, Chrome tracepoints etc.
65                    ''',
66                    joinable='args.arg_set_id'),
67            'machine_id':
68                '''
69                  Machine identifier, non-null for tracks on a remote machine.
70                ''',
71        }))
72
73PROCESS_TRACK_TABLE = Table(
74    python_module=__file__,
75    class_name="ProcessTrackTable",
76    sql_name="process_track",
77    columns=[
78        C("upid", CppUint32()),
79    ],
80    parent=TRACK_TABLE,
81    tabledoc=TableDoc(
82        doc='''
83          Tracks which are associated to the process given by the |upid| column
84        ''',
85        group='Tracks',
86        columns={
87            'upid':
88                ColumnDoc(
89                    doc='The process associated with this track.',
90                    joinable='process.upid'),
91        }))
92
93THREAD_TRACK_TABLE = Table(
94    python_module=__file__,
95    class_name='ThreadTrackTable',
96    sql_name='thread_track',
97    columns=[
98        C('utid', CppUint32()),
99    ],
100    parent=TRACK_TABLE,
101    tabledoc=TableDoc(
102        doc='''
103          Tracks which are associated to the thread given by the |utid| column
104        ''',
105        group='Tracks',
106        columns={
107            'utid':
108                ColumnDoc(
109                    doc='The thread associated with this track',
110                    joinable='thread.utid',
111                )
112        }))
113
114CPU_TRACK_TABLE = Table(
115    python_module=__file__,
116    class_name='CpuTrackTable',
117    sql_name='cpu_track',
118    columns=[
119        C('cpu', CppUint32()),
120    ],
121    parent=TRACK_TABLE,
122    tabledoc=TableDoc(
123        doc='Tracks which are associated to a single CPU',
124        group='Tracks',
125        columns={'cpu': 'The CPU associated with this track'}))
126
127GPU_TRACK_TABLE = Table(
128    python_module=__file__,
129    class_name='GpuTrackTable',
130    sql_name='gpu_track',
131    columns=[
132        C('scope', CppString()),
133        C('description', CppString()),
134        C('context_id', CppOptional(CppInt64())),
135    ],
136    parent=TRACK_TABLE,
137    tabledoc=TableDoc(
138        doc='Tracks associated to a GPU.',
139        group='Tracks',
140        columns={
141            'scope':
142                'The scope for the track. For debugging purposes only.',
143            'description':
144                'The description of the track. For debugging purposes only.',
145            'context_id':
146                'The context id for the GPU this track is associated to.'
147        }))
148
149UID_TRACK_TABLE = Table(
150    python_module=__file__,
151    class_name='UidTrackTable',
152    sql_name='uid_track',
153    columns=[
154        C('uid', CppInt32()),
155    ],
156    parent=TRACK_TABLE,
157    tabledoc=TableDoc(
158        doc='Tracks associated to a UID.',
159        group='Tracks',
160        columns={
161            'uid': 'The uid associated with this track.',
162        }))
163
164GPU_WORK_PERIOD_TRACK_TABLE = Table(
165    python_module=__file__,
166    class_name='GpuWorkPeriodTrackTable',
167    sql_name='gpu_work_period_track',
168    columns=[
169        C('gpu_id', CppUint32()),
170    ],
171    parent=UID_TRACK_TABLE,
172    tabledoc=TableDoc(
173        doc='Tracks containing gpu_work_period events.',
174        group='Tracks',
175        columns={
176            'gpu_id': 'The identifier for the GPU.',
177        }))
178
179COUNTER_TRACK_TABLE = Table(
180    python_module=__file__,
181    class_name='CounterTrackTable',
182    sql_name='counter_track',
183    columns=[
184        C('unit', CppString()),
185        C('description', CppString()),
186    ],
187    parent=TRACK_TABLE,
188    tabledoc=TableDoc(
189        doc='''
190          Tracks containing counter-like events. See
191          https://perfetto.dev/docs/analysis/trace-processor#events for a
192          defintion and examples of counters.
193        ''',
194        group='Tracks',
195        columns={
196            'unit':
197                'The units of the counter. This column is rarely filled.',
198            'description':
199                'The description for this track. For debugging purposes only.'
200        }))
201
202THREAD_COUNTER_TRACK_TABLE = Table(
203    python_module=__file__,
204    class_name='ThreadCounterTrackTable',
205    sql_name='thread_counter_track',
206    columns=[
207        C('utid', CppUint32()),
208    ],
209    parent=COUNTER_TRACK_TABLE,
210    tabledoc=TableDoc(
211        doc='Tracks containing counter-like events associated to a thread.',
212        group='Counter Tracks',
213        columns={
214            'utid':
215                ColumnDoc(
216                    doc='The thread associated with this track',
217                    joinable='thread.utid',
218                )
219        }))
220
221PROCESS_COUNTER_TRACK_TABLE = Table(
222    python_module=__file__,
223    class_name='ProcessCounterTrackTable',
224    sql_name='process_counter_track',
225    columns=[
226        C('upid', CppUint32()),
227    ],
228    parent=COUNTER_TRACK_TABLE,
229    tabledoc=TableDoc(
230        doc='''
231          Tracks containing counter-like events associated to a process.
232        ''',
233        group='Counter Tracks',
234        columns={
235            'upid':
236                ColumnDoc(
237                    doc='The process associated with this track',
238                    joinable='process.upid')
239        }))
240
241CPU_COUNTER_TRACK_TABLE = Table(
242    python_module=__file__,
243    class_name='CpuCounterTrackTable',
244    sql_name='cpu_counter_track',
245    columns=[
246        C('cpu', CppUint32()),
247    ],
248    parent=COUNTER_TRACK_TABLE,
249    tabledoc=TableDoc(
250        doc='Tracks containing counter-like events associated to a CPU.',
251        group='Counter Tracks',
252        columns={'cpu': 'The CPU this track is associated with'}))
253
254IRQ_COUNTER_TRACK_TABLE = Table(
255    python_module=__file__,
256    class_name='IrqCounterTrackTable',
257    sql_name='irq_counter_track',
258    columns=[
259        C('irq', CppInt32()),
260    ],
261    parent=COUNTER_TRACK_TABLE,
262    tabledoc=TableDoc(
263        doc='Tracks containing counter-like events associated to an hardirq',
264        group='Counter Tracks',
265        columns={'irq': 'The identifier for the hardirq.'}))
266
267SOFTIRQ_COUNTER_TRACK_TABLE = Table(
268    python_module=__file__,
269    class_name='SoftirqCounterTrackTable',
270    sql_name='softirq_counter_track',
271    columns=[
272        C('softirq', CppInt32()),
273    ],
274    parent=COUNTER_TRACK_TABLE,
275    tabledoc=TableDoc(
276        doc='Tracks containing counter-like events associated to a softirq',
277        group='Counter Tracks',
278        columns={'softirq': 'The identifier for the softirq.'}))
279
280GPU_COUNTER_TRACK_TABLE = Table(
281    python_module=__file__,
282    class_name='GpuCounterTrackTable',
283    sql_name='gpu_counter_track',
284    columns=[
285        C('gpu_id', CppUint32()),
286    ],
287    parent=COUNTER_TRACK_TABLE,
288    tabledoc=TableDoc(
289        doc='Tracks containing counter-like events associated to a GPU',
290        group='Counter Tracks',
291        columns={'gpu_id': 'The identifier for the GPU.'}))
292
293
294ENERGY_COUNTER_TRACK_TABLE = Table(
295    python_module=__file__,
296    class_name='EnergyCounterTrackTable',
297    sql_name='energy_counter_track',
298    columns=[
299        C('consumer_id', CppInt32()),
300        C('consumer_type', CppString()),
301        C('ordinal', CppInt32()),
302    ],
303    parent=COUNTER_TRACK_TABLE,
304    tabledoc=TableDoc(
305        doc='''
306          Energy consumers' values for energy descriptors in
307          energy_estimation_breakdown packet
308        ''',
309        group='Counter Tracks',
310        columns={
311            'consumer_id': 'id of a distinct energy consumer',
312            'consumer_type': 'type of energy consumer',
313            'ordinal': 'ordinal of energy consumer'
314        }))
315
316LINUX_DEVICE_TRACK_TABLE = Table(
317    python_module=__file__,
318    class_name='LinuxDeviceTrackTable',
319    sql_name='linux_device_track',
320    columns=[],
321    parent=TRACK_TABLE,
322    tabledoc=TableDoc(
323        doc='''
324          Slice data corresponding to runtime power state transitions
325          associated with Linux devices (where a Linux device is anything
326          managed by a Linux driver). The name of each track corresponds to the
327          device name as recognized by the linux kernel running on the system.
328        ''',
329        group='Tracks',
330        # No additional columns are needed because the track name implicitly
331        # serves as the device name, providing all required information.
332        columns={}))
333
334UID_COUNTER_TRACK_TABLE = Table(
335    python_module=__file__,
336    class_name='UidCounterTrackTable',
337    sql_name='uid_counter_track',
338    columns=[
339        C('uid', CppInt32()),
340    ],
341    parent=COUNTER_TRACK_TABLE,
342    tabledoc=TableDoc(
343        doc='The uid associated with this track',
344        group='Counter Tracks',
345        columns={'uid': 'uid of process for which breakdowns are emitted'}))
346
347ENERGY_PER_UID_COUNTER_TRACK_TABLE = Table(
348    python_module=__file__,
349    class_name='EnergyPerUidCounterTrackTable',
350    sql_name='energy_per_uid_counter_track',
351    columns=[
352        C('consumer_id', CppInt32()),
353    ],
354    parent=UID_COUNTER_TRACK_TABLE,
355    tabledoc=TableDoc(
356        doc='Energy consumer values for per uid in uid_counter_track',
357        group='Counter Tracks',
358        columns={'consumer_id': 'id of the consumer process'}))
359
360# Keep this list sorted.
361ALL_TABLES = [
362    COUNTER_TRACK_TABLE,
363    CPU_COUNTER_TRACK_TABLE,
364    CPU_TRACK_TABLE,
365    ENERGY_COUNTER_TRACK_TABLE,
366    ENERGY_PER_UID_COUNTER_TRACK_TABLE,
367    GPU_COUNTER_TRACK_TABLE,
368    GPU_TRACK_TABLE,
369    GPU_WORK_PERIOD_TRACK_TABLE,
370    IRQ_COUNTER_TRACK_TABLE,
371    LINUX_DEVICE_TRACK_TABLE,
372    PROCESS_COUNTER_TRACK_TABLE,
373    PROCESS_TRACK_TABLE,
374    SOFTIRQ_COUNTER_TRACK_TABLE,
375    THREAD_COUNTER_TRACK_TABLE,
376    THREAD_TRACK_TABLE,
377    TRACK_TABLE,
378    UID_COUNTER_TRACK_TABLE,
379    UID_TRACK_TABLE,
380]
381