• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1--
2-- Copyright 2024 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--     https://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
16INCLUDE PERFETTO MODULE prelude.after_eof.views;
17
18-- Lists all metrics built-into trace processor.
19CREATE PERFETTO VIEW trace_metrics (
20  -- The name of the metric.
21  name STRING
22) AS
23SELECT
24  name
25FROM _trace_metrics;
26
27-- Definition of `trace_bounds` table. The values are being filled by Trace
28-- Processor when parsing the trace.
29-- It is recommended to depend on the `trace_start()` and `trace_end()`
30-- functions rather than directly on `trace_bounds`.
31CREATE PERFETTO VIEW trace_bounds (
32  -- First ts in the trace.
33  start_ts TIMESTAMP,
34  -- End of the trace.
35  end_ts TIMESTAMP
36) AS
37SELECT
38  start_ts,
39  end_ts
40FROM _trace_bounds;
41
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.
46CREATE PERFETTO VIEW track (
47  -- Unique identifier for this track. Identical to |track_id|, prefer using
48  -- |track_id| instead.
49  id ID,
50  -- Name of the track; can be null for some types of tracks (e.g. thread
51  -- tracks).
52  name STRING,
53  -- The type of a track indicates the type of data the track contains.
54  --
55  -- Every track is uniquely identified by the the combination of the
56  -- type and a set of dimensions: type allow identifying a set of tracks
57  -- with the same type of data within the whole universe of tracks while
58  -- dimensions allow distinguishing between different tracks in that set.
59  type STRING,
60  -- The dimensions of the track which uniquely identify the track within a
61  -- given `type`.
62  --
63  -- Join with the `args` table or use the `EXTRACT_ARG` helper function to
64  -- expand the args.
65  dimension_arg_set_id ARGSETID,
66  -- The track which is the "parent" of this track. Only non-null for tracks
67  -- created using Perfetto's track_event API.
68  parent_id JOINID(track.id),
69  -- Generic key-value pairs containing extra information about the track.
70  --
71  -- Join with the `args` table or use the `EXTRACT_ARG` helper function to
72  -- expand the args.
73  source_arg_set_id ARGSETID,
74  -- Machine identifier, non-null for tracks on a remote machine.
75  machine_id LONG
76) AS
77SELECT
78  id,
79  name,
80  type,
81  dimension_arg_set_id,
82  parent_id,
83  source_arg_set_id,
84  machine_id
85FROM __intrinsic_track;
86
87-- Contains information about the CPUs on the device this trace was taken on.
88CREATE PERFETTO VIEW cpu (
89  -- Unique identifier for this CPU. Identical to |ucpu|, prefer using |ucpu|
90  -- instead.
91  id ID,
92  -- Unique identifier for this CPU. Isn't equal to |cpu| for remote machines
93  -- and is equal to |cpu| for the host machine.
94  ucpu ID,
95  -- The 0-based CPU core identifier.
96  cpu LONG,
97  -- The cluster id is shared by CPUs in the same cluster.
98  cluster_id LONG,
99  -- A string describing this core.
100  processor STRING,
101  -- Machine identifier, non-null for CPUs on a remote machine.
102  machine_id LONG,
103  -- Capacity of a CPU of a device, a metric which indicates the
104  -- relative performance of a CPU on a device
105  -- For details see:
106  -- https://www.kernel.org/doc/Documentation/devicetree/bindings/arm/cpu-capacity.txt
107  capacity LONG,
108  -- Extra key/value pairs associated with this cpu.
109  arg_set_id ARGSETID
110) AS
111SELECT
112  id,
113  id AS ucpu,
114  cpu,
115  cluster_id,
116  processor,
117  machine_id,
118  capacity,
119  arg_set_id
120FROM __intrinsic_cpu
121WHERE
122  cpu IS NOT NULL;
123
124-- Contains the frequency values that the CPUs on the device are capable of
125-- running at.
126CREATE PERFETTO VIEW cpu_available_frequencies (
127  -- Unique identifier for this cpu frequency.
128  id ID,
129  -- The CPU for this frequency, meaningful only in single machine traces.
130  -- For multi-machine, join with the `cpu` table on `ucpu` to get the CPU
131  -- identifier of each machine.
132  cpu LONG,
133  -- CPU frequency in KHz.
134  freq LONG,
135  -- The CPU that the slice executed on (meaningful only in single machine
136  -- traces). For multi-machine, join with the `cpu` table on `ucpu` to get the
137  -- CPU identifier of each machine.
138  ucpu LONG
139) AS
140SELECT
141  id,
142  ucpu AS cpu,
143  freq,
144  ucpu
145FROM __intrinsic_cpu_freq;
146
147-- This table holds slices with kernel thread scheduling information. These
148-- slices are collected when the Linux "ftrace" data source is used with the
149-- "sched/switch" and "sched/wakeup*" events enabled.
150--
151-- The rows in this table will always have a matching row in the |thread_state|
152-- table with |thread_state.state| = 'Running'
153CREATE PERFETTO VIEW sched_slice (
154  --  Unique identifier for this scheduling slice.
155  id ID,
156  -- The timestamp at the start of the slice.
157  ts TIMESTAMP,
158  -- The duration of the slice.
159  dur DURATION,
160  -- The CPU that the slice executed on (meaningful only in single machine
161  -- traces). For multi-machine, join with the `cpu` table on `ucpu` to get the
162  -- CPU identifier of each machine.
163  cpu LONG,
164  -- The thread's unique id in the trace.
165  utid JOINID(thread.id),
166  -- A string representing the scheduling state of the kernel
167  -- thread at the end of the slice.  The individual characters in
168  -- the string mean the following: R (runnable), S (awaiting a
169  -- wakeup), D (in an uninterruptible sleep), T (suspended),
170  -- t (being traced), X (exiting), P (parked), W (waking),
171  -- I (idle), N (not contributing to the load average),
172  -- K (wakeable on fatal signals) and Z (zombie, awaiting
173  -- cleanup).
174  end_state STRING,
175  -- The kernel priority that the thread ran at.
176  priority LONG,
177  -- The unique CPU identifier that the slice executed on.
178  ucpu LONG
179) AS
180SELECT
181  id,
182  ts,
183  dur,
184  ucpu AS cpu,
185  utid,
186  end_state,
187  priority,
188  ucpu
189FROM __intrinsic_sched_slice;
190
191-- Shorter alias for table `sched_slice`.
192CREATE PERFETTO VIEW sched (
193  -- Alias for `sched_slice.id`.
194  id ID,
195  -- Alias for `sched_slice.ts`.
196  ts TIMESTAMP,
197  -- Alias for `sched_slice.dur`.
198  dur DURATION,
199  -- Alias for `sched_slice.cpu`.
200  cpu LONG,
201  -- Alias for `sched_slice.utid`.
202  utid JOINID(thread.id),
203  -- Alias for `sched_slice.end_state`.
204  end_state STRING,
205  -- Alias for `sched_slice.priority`.
206  priority LONG,
207  -- Alias for `sched_slice.ucpu`.
208  ucpu LONG,
209  -- Legacy column, should no longer be used.
210  ts_end LONG
211) AS
212SELECT
213  *,
214  ts + dur AS ts_end
215FROM sched_slice;
216
217-- This table contains the scheduling state of every thread on the system during
218-- the trace.
219--
220-- The rows in this table which have |state| = 'Running', will have a
221-- corresponding row in the |sched_slice| table.
222CREATE PERFETTO VIEW thread_state (
223  -- Unique identifier for this thread state.
224  id ID,
225  -- The timestamp at the start of the slice.
226  ts TIMESTAMP,
227  -- The duration of the slice.
228  dur DURATION,
229  -- The CPU that the thread executed on (meaningful only in single machine
230  -- traces). For multi-machine, join with the `cpu` table on `ucpu` to get the
231  -- CPU identifier of each machine.
232  cpu LONG,
233  -- The thread's unique id in the trace.
234  utid JOINID(thread.id),
235  -- The scheduling state of the thread. Can be "Running" or any of the states
236  -- described in |sched_slice.end_state|.
237  state STRING,
238  -- Indicates whether this thread was blocked on IO.
239  io_wait LONG,
240  -- The function in the kernel this thread was blocked on.
241  blocked_function STRING,
242  -- The unique thread id of the thread which caused a wakeup of this thread.
243  waker_utid JOINID(thread.id),
244  -- The unique thread state id which caused a wakeup of this thread.
245  waker_id JOINID(thread_state.id),
246  -- Whether the wakeup was from interrupt context or process context.
247  irq_context LONG,
248  -- The unique CPU identifier that the thread executed on.
249  ucpu LONG
250) AS
251SELECT
252  id,
253  ts,
254  dur,
255  ucpu AS cpu,
256  utid,
257  state,
258  io_wait,
259  blocked_function,
260  waker_utid,
261  waker_id,
262  irq_context,
263  ucpu
264FROM __intrinsic_thread_state;
265
266-- Contains all the ftrace events in the trace. This table exists only for
267-- debugging purposes and should not be relied on in production usecases (i.e.
268-- metrics, standard library etc). Note also that this table might be empty if
269-- raw ftrace parsing has been disabled.
270CREATE PERFETTO VIEW ftrace_event (
271  -- Unique identifier for this ftrace event.
272  id ID,
273  -- The timestamp of this event.
274  ts TIMESTAMP,
275  -- The ftrace event name.
276  name STRING,
277  -- The CPU this event was emitted on (meaningful only in single machine
278  -- traces). For multi-machine, join with the `cpu` table on `ucpu` to get the
279  -- CPU identifier of each machine.
280  cpu LONG,
281  -- The thread this event was emitted on.
282  utid JOINID(thread.id),
283  -- The set of key/value pairs associated with this event.
284  arg_set_id ARGSETID,
285  -- Ftrace event flags for this event. Currently only emitted for
286  -- sched_waking events.
287  common_flags LONG,
288  -- The unique CPU identifier that this event was emitted on.
289  ucpu LONG
290) AS
291SELECT
292  id,
293  ts,
294  name,
295  ucpu AS cpu,
296  utid,
297  arg_set_id,
298  common_flags,
299  ucpu
300FROM __intrinsic_ftrace_event;
301
302-- This table is deprecated. Use `ftrace_event` instead which contains the same
303-- rows; this table is simply a (badly named) alias.
304CREATE PERFETTO VIEW raw (
305  -- Unique identifier for this raw event.
306  id ID,
307  -- The timestamp of this event.
308  ts TIMESTAMP,
309  -- The name of the event. For ftrace events, this will be the ftrace event
310  -- name.
311  name STRING,
312  -- The CPU this event was emitted on (meaningful only in single machine
313  -- traces). For multi-machine, join with the `cpu` table on `ucpu` to get the
314  -- CPU identifier of each machine.
315  cpu LONG,
316  -- The thread this event was emitted on.
317  utid JOINID(thread.id),
318  -- The set of key/value pairs associated with this event.
319  arg_set_id ARGSETID,
320  -- Ftrace event flags for this event. Currently only emitted for sched_waking
321  -- events.
322  common_flags LONG,
323  -- The unique CPU identifier that this event was emitted on.
324  ucpu LONG
325) AS
326SELECT
327  *
328FROM ftrace_event;
329
330-- Tracks which are associated to a single thread.
331CREATE PERFETTO TABLE thread_track (
332  -- Unique identifier for this thread track.
333  id ID(track.id),
334  -- Name of the track.
335  name STRING,
336  -- The type of a track indicates the type of data the track contains.
337  --
338  -- Every track is uniquely identified by the the combination of the
339  -- type and a set of dimensions: type allow identifying a set of tracks
340  -- with the same type of data within the whole universe of tracks while
341  -- dimensions allow distinguishing between different tracks in that set.
342  type STRING,
343  -- The track which is the "parent" of this track. Only non-null for tracks
344  -- created using Perfetto's track_event API.
345  parent_id JOINID(track.id),
346  -- Args for this track which store information about "source" of this track in
347  -- the trace. For example: whether this track orginated from atrace, Chrome
348  -- tracepoints etc.
349  source_arg_set_id ARGSETID,
350  -- Machine identifier, non-null for tracks on a remote machine.
351  machine_id LONG,
352  -- The utid that the track is associated with.
353  utid JOINID(thread.id)
354) AS
355SELECT
356  t.id,
357  t.name,
358  t.type,
359  t.parent_id,
360  t.source_arg_set_id,
361  t.machine_id,
362  a.int_value AS utid
363FROM __intrinsic_track AS t
364JOIN args AS a
365  ON t.dimension_arg_set_id = a.arg_set_id
366WHERE
367  t.event_type = 'slice' AND a.key = 'utid';
368
369-- Tracks which are associated to a single process.
370CREATE PERFETTO TABLE process_track (
371  -- Unique identifier for this process track.
372  id ID(track.id),
373  -- Name of the track.
374  name STRING,
375  -- The type of a track indicates the type of data the track contains.
376  --
377  -- Every track is uniquely identified by the the combination of the
378  -- type and a set of dimensions: type allow identifying a set of tracks
379  -- with the same type of data within the whole universe of tracks while
380  -- dimensions allow distinguishing between different tracks in that set.
381  type STRING,
382  -- The track which is the "parent" of this track. Only non-null for tracks
383  -- created using Perfetto's track_event API.
384  parent_id JOINID(track.id),
385  -- Args for this track which store information about "source" of this track in
386  -- the trace. For example: whether this track orginated from atrace, Chrome
387  -- tracepoints etc.
388  source_arg_set_id ARGSETID,
389  -- Machine identifier, non-null for tracks on a remote machine.
390  machine_id LONG,
391  -- The upid that the track is associated with.
392  upid JOINID(process.id)
393) AS
394SELECT
395  t.id,
396  t.name,
397  t.type,
398  t.parent_id,
399  t.source_arg_set_id,
400  t.machine_id,
401  a.int_value AS upid
402FROM __intrinsic_track AS t
403JOIN args AS a
404  ON t.dimension_arg_set_id = a.arg_set_id
405WHERE
406  t.event_type = 'slice' AND a.key = 'upid';
407
408-- Tracks which are associated to a single CPU.
409CREATE PERFETTO TABLE cpu_track (
410  -- Unique identifier for this cpu track.
411  id ID(track.id),
412  -- Name of the track.
413  name STRING,
414  -- The type of a track indicates the type of data the track contains.
415  --
416  -- Every track is uniquely identified by the the combination of the
417  -- type and a set of dimensions: type allow identifying a set of tracks
418  -- with the same type of data within the whole universe of tracks while
419  -- dimensions allow distinguishing between different tracks in that set.
420  type STRING,
421  -- The track which is the "parent" of this track. Only non-null for tracks
422  -- created using Perfetto's track_event API.
423  parent_id JOINID(track.id),
424  -- Args for this track which store information about "source" of this track in
425  -- the trace. For example: whether this track orginated from atrace, Chrome
426  -- tracepoints etc.
427  source_arg_set_id ARGSETID,
428  -- Machine identifier, non-null for tracks on a remote machine.
429  machine_id LONG,
430  -- The CPU that the track is associated with.
431  cpu LONG
432) AS
433SELECT
434  t.id,
435  t.name,
436  t.type,
437  t.parent_id,
438  t.source_arg_set_id,
439  t.machine_id,
440  a.int_value AS cpu
441FROM __intrinsic_track AS t
442JOIN args AS a
443  ON t.dimension_arg_set_id = a.arg_set_id
444WHERE
445  t.event_type = 'slice' AND a.key = 'cpu';
446
447-- Table containing tracks which are loosely tied to a GPU.
448--
449-- NOTE: this table is deprecated due to inconsistency of it's design with
450-- other track tables (e.g. not having a GPU column, mixing a bunch of different
451-- tracks which are barely related). Please use the track table directly
452-- instead.
453CREATE PERFETTO TABLE gpu_track (
454  -- Unique identifier for this cpu track.
455  id ID(track.id),
456  -- Name of the track.
457  name STRING,
458  -- The type of a track indicates the type of data the track contains.
459  --
460  -- Every track is uniquely identified by the the combination of the
461  -- type and a set of dimensions: type allow identifying a set of tracks
462  -- with the same type of data within the whole universe of tracks while
463  -- dimensions allow distinguishing between different tracks in that set.
464  type STRING,
465  -- The track which is the "parent" of this track. Only non-null for tracks
466  -- created using Perfetto's track_event API.
467  parent_id JOINID(track.id),
468  -- Args for this track which store information about "source" of this track in
469  -- the trace. For example: whether this track orginated from atrace, Chrome
470  -- tracepoints etc.
471  source_arg_set_id ARGSETID,
472  -- The dimensions of the track which uniquely identify the track within a
473  -- given type.
474  dimension_arg_set_id ARGSETID,
475  -- Machine identifier, non-null for tracks on a remote machine.
476  machine_id LONG,
477  -- The source of the track. Deprecated.
478  scope STRING,
479  -- The description for the track.
480  description STRING,
481  -- The context id for the GPU this track is associated to.
482  context_id LONG
483) AS
484SELECT
485  id,
486  name,
487  type,
488  parent_id,
489  source_arg_set_id,
490  dimension_arg_set_id,
491  machine_id,
492  type AS scope,
493  extract_arg(source_arg_set_id, 'description') AS description,
494  extract_arg(dimension_arg_set_id, 'context_id') AS context_id
495FROM __intrinsic_track
496WHERE
497  type IN ('drm_vblank', 'drm_sched_ring', 'drm_fence', 'mali_mcu_state', 'gpu_render_stage', 'vulkan_events', 'gpu_log', 'graphics_frame_event');
498
499-- Tracks containing counter-like events.
500CREATE PERFETTO VIEW counter_track (
501  -- Unique identifier for this cpu counter track.
502  id ID(track.id),
503  -- Name of the track.
504  name STRING,
505  -- The track which is the "parent" of this track. Only non-null for tracks
506  -- created using Perfetto's track_event API.
507  parent_id JOINID(track.id),
508  -- The type of a track indicates the type of data the track contains.
509  --
510  -- Every track is uniquely identified by the the combination of the
511  -- type and a set of dimensions: type allow identifying a set of tracks
512  -- with the same type of data within the whole universe of tracks while
513  -- dimensions allow distinguishing between different tracks in that set.
514  type STRING,
515  -- The dimensions of the track which uniquely identify the track within a
516  -- given type.
517  dimension_arg_set_id ARGSETID,
518  -- Args for this track which store information about "source" of this track in
519  -- the trace. For example: whether this track orginated from atrace, Chrome
520  -- tracepoints etc.
521  source_arg_set_id ARGSETID,
522  -- Machine identifier, non-null for tracks on a remote machine.
523  machine_id LONG,
524  -- The units of the counter. This column is rarely filled.
525  unit STRING,
526  -- The description for this track. For debugging purposes only.
527  description STRING
528) AS
529SELECT
530  id,
531  name,
532  NULL AS parent_id,
533  type,
534  dimension_arg_set_id,
535  source_arg_set_id,
536  machine_id,
537  counter_unit AS unit,
538  extract_arg(source_arg_set_id, 'description') AS description
539FROM __intrinsic_track
540WHERE
541  event_type = 'counter';
542
543-- Tracks containing counter-like events associated to a CPU.
544CREATE PERFETTO TABLE cpu_counter_track (
545  -- Unique identifier for this cpu counter track.
546  id ID(track.id),
547  -- Name of the track.
548  name STRING,
549  -- The type of a track indicates the type of data the track contains.
550  --
551  -- Every track is uniquely identified by the the combination of the
552  -- type and a set of dimensions: type allow identifying a set of tracks
553  -- with the same type of data within the whole universe of tracks while
554  -- dimensions allow distinguishing between different tracks in that set.
555  type STRING,
556  -- The track which is the "parent" of this track. Only non-null for tracks
557  -- created using Perfetto's track_event API.
558  parent_id JOINID(track.id),
559  -- Args for this track which store information about "source" of this track in
560  -- the trace. For example: whether this track orginated from atrace, Chrome
561  -- tracepoints etc.
562  source_arg_set_id ARGSETID,
563  -- Machine identifier, non-null for tracks on a remote machine.
564  machine_id LONG,
565  -- The units of the counter. This column is rarely filled.
566  unit STRING,
567  -- The description for this track. For debugging purposes only.
568  description STRING,
569  -- The CPU that the track is associated with.
570  cpu LONG
571) AS
572SELECT
573  ct.id,
574  ct.name,
575  ct.type,
576  ct.parent_id,
577  ct.source_arg_set_id,
578  ct.machine_id,
579  ct.unit,
580  ct.description,
581  args.int_value AS cpu
582FROM counter_track AS ct
583JOIN args
584  ON ct.dimension_arg_set_id = args.arg_set_id
585WHERE
586  args.key = 'cpu';
587
588-- Tracks containing counter-like events associated to a GPU.
589CREATE PERFETTO TABLE gpu_counter_track (
590  -- Unique identifier for this gpu counter track.
591  id ID(track.id),
592  -- Name of the track.
593  name STRING,
594  -- The type of a track indicates the type of data the track contains.
595  --
596  -- Every track is uniquely identified by the the combination of the
597  -- type and a set of dimensions: type allow identifying a set of tracks
598  -- with the same type of data within the whole universe of tracks while
599  -- dimensions allow distinguishing between different tracks in that set.
600  type STRING,
601  -- The track which is the "parent" of this track. Only non-null for tracks
602  -- created using Perfetto's track_event API.
603  parent_id JOINID(track.id),
604  -- Args for this track which store information about "source" of this track in
605  -- the trace. For example: whether this track orginated from atrace, Chrome
606  -- tracepoints etc.
607  source_arg_set_id ARGSETID,
608  -- Machine identifier, non-null for tracks on a remote machine.
609  machine_id LONG,
610  -- The units of the counter. This column is rarely filled.
611  unit STRING,
612  -- The description for this track. For debugging purposes only.
613  description STRING,
614  -- The GPU that the track is associated with.
615  gpu_id LONG
616) AS
617SELECT
618  ct.id,
619  ct.name,
620  ct.type,
621  ct.parent_id,
622  ct.source_arg_set_id,
623  ct.machine_id,
624  ct.unit,
625  ct.description,
626  args.int_value AS gpu_id
627FROM counter_track AS ct
628JOIN args
629  ON ct.dimension_arg_set_id = args.arg_set_id
630WHERE
631  args.key = 'gpu';
632
633-- Tracks containing counter-like events associated to a process.
634CREATE PERFETTO TABLE process_counter_track (
635  -- Unique identifier for this process counter track.
636  id ID(track.id),
637  -- Name of the track.
638  name STRING,
639  -- The type of a track indicates the type of data the track contains.
640  --
641  -- Every track is uniquely identified by the the combination of the
642  -- type and a set of dimensions: type allow identifying a set of tracks
643  -- with the same type of data within the whole universe of tracks while
644  -- dimensions allow distinguishing between different tracks in that set.
645  type STRING,
646  -- The track which is the "parent" of this track. Only non-null for tracks
647  -- created using Perfetto's track_event API.
648  parent_id JOINID(track.id),
649  -- Args for this track which store information about "source" of this track in
650  -- the trace. For example: whether this track orginated from atrace, Chrome
651  -- tracepoints etc.
652  source_arg_set_id ARGSETID,
653  -- Machine identifier, non-null for tracks on a remote machine.
654  machine_id LONG,
655  -- The units of the counter. This column is rarely filled.
656  unit STRING,
657  -- The description for this track. For debugging purposes only.
658  description STRING,
659  -- The upid of the process that the track is associated with.
660  upid LONG
661) AS
662SELECT
663  ct.id,
664  ct.name,
665  ct.type,
666  ct.parent_id,
667  ct.source_arg_set_id,
668  ct.machine_id,
669  ct.unit,
670  ct.description,
671  args.int_value AS upid
672FROM counter_track AS ct
673JOIN args
674  ON ct.dimension_arg_set_id = args.arg_set_id
675WHERE
676  args.key = 'upid';
677
678-- Tracks containing counter-like events associated to a thread.
679CREATE PERFETTO TABLE thread_counter_track (
680  -- Unique identifier for this thread counter track.
681  id ID(track.id),
682  -- Name of the track.
683  name STRING,
684  -- The type of a track indicates the type of data the track contains.
685  --
686  -- Every track is uniquely identified by the the combination of the
687  -- type and a set of dimensions: type allow identifying a set of tracks
688  -- with the same type of data within the whole universe of tracks while
689  -- dimensions allow distinguishing between different tracks in that set.
690  type STRING,
691  -- The track which is the "parent" of this track. Only non-null for tracks
692  -- created using Perfetto's track_event API.
693  parent_id JOINID(track.id),
694  -- Args for this track which store information about "source" of this track in
695  -- the trace. For example: whether this track orginated from atrace, Chrome
696  -- tracepoints etc.
697  source_arg_set_id JOINID(track.id),
698  -- Machine identifier, non-null for tracks on a remote machine.
699  machine_id LONG,
700  -- The units of the counter. This column is rarely filled.
701  unit STRING,
702  -- The description for this track. For debugging purposes only.
703  description STRING,
704  -- The utid of the thread that the track is associated with.
705  utid LONG
706) AS
707SELECT
708  ct.id,
709  ct.name,
710  ct.type,
711  ct.parent_id,
712  ct.source_arg_set_id,
713  ct.machine_id,
714  ct.unit,
715  ct.description,
716  args.int_value AS utid
717FROM counter_track AS ct
718JOIN args
719  ON ct.dimension_arg_set_id = args.arg_set_id
720WHERE
721  args.key = 'utid';
722
723-- Tracks containing counter-like events collected from Linux perf.
724CREATE PERFETTO TABLE perf_counter_track (
725  -- Unique identifier for this thread counter track.
726  id ID(track.id),
727  -- Name of the track.
728  name STRING,
729  -- The type of a track indicates the type of data the track contains.
730  --
731  -- Every track is uniquely identified by the the combination of the
732  -- type and a set of dimensions: type allow identifying a set of tracks
733  -- with the same type of data within the whole universe of tracks while
734  -- dimensions allow distinguishing between different tracks in that set.
735  type STRING,
736  -- The track which is the "parent" of this track. Only non-null for tracks
737  -- created using Perfetto's track_event API.
738  parent_id JOINID(track.id),
739  -- Args for this track which store information about "source" of this track in
740  -- the trace. For example: whether this track orginated from atrace, Chrome
741  -- tracepoints etc.
742  source_arg_set_id ARGSETID,
743  -- Machine identifier, non-null for tracks on a remote machine.
744  machine_id LONG,
745  -- The units of the counter. This column is rarely filled.
746  unit STRING,
747  -- The description for this track. For debugging purposes only.
748  description STRING,
749  -- The id of the perf session this counter was captured on.
750  perf_session_id LONG,
751  -- The CPU the counter is associated with.
752  cpu LONG,
753  -- Whether this counter is the sampling timebase for the session.
754  is_timebase BOOL
755) AS
756SELECT
757  ct.id,
758  ct.name,
759  ct.type,
760  ct.parent_id,
761  ct.source_arg_set_id,
762  ct.machine_id,
763  ct.unit,
764  ct.description,
765  extract_arg(ct.dimension_arg_set_id, 'perf_session_id') AS perf_session_id,
766  extract_arg(ct.dimension_arg_set_id, 'cpu') AS cpu,
767  extract_arg(ct.source_arg_set_id, 'is_timebase') AS is_timebase
768FROM counter_track AS ct
769WHERE
770  ct.type = 'perf_counter';
771
772-- Alias of the `counter` table.
773CREATE PERFETTO VIEW counters (
774  -- Alias of `counter.id`.
775  id ID,
776  -- Alias of `counter.ts`.
777  ts TIMESTAMP,
778  -- Alias of `counter.track_id`.
779  track_id JOINID(track.id),
780  -- Alias of `counter.value`.
781  value DOUBLE,
782  -- Alias of `counter.arg_set_id`.
783  arg_set_id LONG,
784  -- Legacy column, should no longer be used.
785  name STRING,
786  -- Legacy column, should no longer be used.
787  unit STRING
788) AS
789SELECT
790  v.*,
791  t.name,
792  t.unit
793FROM counter AS v
794JOIN counter_track AS t
795  ON v.track_id = t.id
796ORDER BY
797  ts;
798
799-- Table containing graphics frame events on Android.
800CREATE PERFETTO VIEW frame_slice (
801  -- Alias of `slice.id`.
802  id ID(slice.id),
803  -- Alias of `slice.ts`.
804  ts TIMESTAMP,
805  -- Alias of `slice.dur`.
806  dur DURATION,
807  -- Alias of `slice.track_id`.
808  track_id JOINID(track.id),
809  -- Alias of `slice.category`.
810  category STRING,
811  -- Alias of `slice.name`.
812  name STRING,
813  -- Alias of `slice.depth`.
814  depth LONG,
815  -- Alias of `slice.parent_id`.
816  parent_id JOINID(frame_slice.id),
817  -- Alias of `slice.arg_set_id`.
818  arg_set_id LONG,
819  -- Name of the graphics layer this slice happened on.
820  layer_name STRING,
821  -- The frame number this slice is associated with.
822  frame_number LONG,
823  -- The time between queue and acquire for this buffer and layer.
824  queue_to_acquire_time LONG,
825  -- The time between acquire and latch for this buffer and layer.
826  acquire_to_latch_time LONG,
827  -- The time between latch and present for this buffer and layer.
828  latch_to_present_time LONG
829) AS
830SELECT
831  s.id,
832  s.ts,
833  s.dur,
834  s.track_id,
835  s.category,
836  s.name,
837  s.depth,
838  s.parent_id,
839  s.arg_set_id,
840  extract_arg(s.arg_set_id, 'layer_name') AS layer_name,
841  extract_arg(s.arg_set_id, 'frame_number') AS frame_number,
842  extract_arg(s.arg_set_id, 'queue_to_acquire_time') AS queue_to_acquire_time,
843  extract_arg(s.arg_set_id, 'acquire_to_latch_time') AS acquire_to_latch_time,
844  extract_arg(s.arg_set_id, 'latch_to_present_time') AS latch_to_present_time
845FROM slice AS s
846JOIN track AS t
847  ON s.track_id = t.id
848WHERE
849  t.type = 'graphics_frame_event';
850
851-- Table containing graphics frame events on Android.
852CREATE PERFETTO VIEW gpu_slice (
853  -- Alias of `slice.id`.
854  id ID(slice.id),
855  -- Alias of `slice.ts`.
856  ts TIMESTAMP,
857  -- Alias of `slice.dur`.
858  dur DURATION,
859  -- Alias of `slice.track_id`.
860  track_id JOINID(track.id),
861  -- Alias of `slice.category`.
862  category STRING,
863  -- Alias of `slice.name`.
864  name STRING,
865  -- Alias of `slice.depth`.
866  depth LONG,
867  -- Alias of `slice.parent_id`.
868  parent_id JOINID(frame_slice.id),
869  -- Alias of `slice.arg_set_id`.
870  arg_set_id LONG,
871  -- Context ID.
872  context_id LONG,
873  -- Render target ID.
874  render_target LONG,
875  -- The name of the render target.
876  render_target_name STRING,
877  -- Render pass ID.
878  render_pass LONG,
879  -- The name of the render pass.
880  render_pass_name STRING,
881  -- The command buffer ID.
882  command_buffer LONG,
883  -- The name of the command buffer.
884  command_buffer_name STRING,
885  -- Frame id.
886  frame_id LONG,
887  -- The submission id.
888  submission_id LONG,
889  -- The hardware queue id.
890  hw_queue_id LONG,
891  -- The id of the process.
892  upid JOINID(process.id),
893  -- Render subpasses.
894  render_subpasses STRING
895) AS
896SELECT
897  s.id,
898  s.ts,
899  s.dur,
900  s.track_id,
901  s.category,
902  s.name,
903  s.depth,
904  s.parent_id,
905  s.arg_set_id,
906  extract_arg(s.arg_set_id, 'context_id') AS context_id,
907  extract_arg(s.arg_set_id, 'render_target') AS render_target,
908  extract_arg(s.arg_set_id, 'render_target_name') AS render_target_name,
909  extract_arg(s.arg_set_id, 'render_pass') AS render_pass,
910  extract_arg(s.arg_set_id, 'render_pass_name') AS render_pass_name,
911  extract_arg(s.arg_set_id, 'command_buffer') AS command_buffer,
912  extract_arg(s.arg_set_id, 'command_buffer_name') AS command_buffer_name,
913  extract_arg(s.arg_set_id, 'frame_id') AS frame_id,
914  extract_arg(s.arg_set_id, 'submission_id') AS submission_id,
915  extract_arg(s.arg_set_id, 'hw_queue_id') AS hw_queue_id,
916  extract_arg(s.arg_set_id, 'upid') AS upid,
917  extract_arg(s.arg_set_id, 'render_subpasses') AS render_subpasses
918FROM slice AS s
919JOIN track AS t
920  ON s.track_id = t.id
921WHERE
922  t.type IN ('gpu_render_stage', 'vulkan_events', 'gpu_log');
923
924-- This table contains information on the expected timeline of either a display
925-- frame or a surface frame.
926CREATE PERFETTO TABLE expected_frame_timeline_slice (
927  -- Alias of `slice.id`.
928  id ID(slice.id),
929  -- Alias of `slice.ts`.
930  ts TIMESTAMP,
931  -- Alias of `slice.dur`.
932  dur DURATION,
933  -- Alias of `slice.track_id`.
934  track_id JOINID(track.id),
935  -- Alias of `slice.category`.
936  category STRING,
937  -- Alias of `slice.name`.
938  name STRING,
939  -- Alias of `slice.depth`.
940  depth LONG,
941  -- Alias of `slice.parent_id`.
942  parent_id JOINID(frame_slice.id),
943  -- Alias of `slice.arg_set_id`.
944  arg_set_id LONG,
945  -- Display frame token (vsync id).
946  display_frame_token LONG,
947  -- Surface frame token (vsync id), null if this is a display frame.
948  surface_frame_token LONG,
949  -- Unique process id of the app that generates the surface frame.
950  upid JOINID(process.id),
951  -- Layer name if this is a surface frame.
952  layer_name STRING
953) AS
954SELECT
955  s.id,
956  s.ts,
957  s.dur,
958  s.track_id,
959  s.category,
960  s.name,
961  s.depth,
962  s.parent_id,
963  s.arg_set_id,
964  extract_arg(s.arg_set_id, 'Display frame token') AS display_frame_token,
965  extract_arg(s.arg_set_id, 'Surface frame token') AS surface_frame_token,
966  t.upid,
967  extract_arg(s.arg_set_id, 'Layer name') AS layer_name
968FROM slice AS s
969JOIN process_track AS t
970  ON s.track_id = t.id
971WHERE
972  t.type = 'android_expected_frame_timeline';
973
974-- This table contains information on the actual timeline and additional
975-- analysis related to the performance of either a display frame or a surface
976-- frame.
977CREATE PERFETTO TABLE actual_frame_timeline_slice (
978  -- Alias of `slice.id`.
979  id ID(slice.id),
980  -- Alias of `slice.ts`.
981  ts TIMESTAMP,
982  -- Alias of `slice.dur`.
983  dur DURATION,
984  -- Alias of `slice.track_id`.
985  track_id JOINID(track.id),
986  -- Alias of `slice.category`.
987  category STRING,
988  -- Alias of `slice.name`.
989  name STRING,
990  -- Alias of `slice.depth`.
991  depth LONG,
992  -- Alias of `slice.parent_id`.
993  parent_id JOINID(frame_slice.id),
994  -- Alias of `slice.arg_set_id`.
995  arg_set_id LONG,
996  -- Display frame token (vsync id).
997  display_frame_token LONG,
998  -- Surface frame token (vsync id), null if this is a display frame.
999  surface_frame_token LONG,
1000  -- Unique process id of the app that generates the surface frame.
1001  upid JOINID(process.id),
1002  -- Layer name if this is a surface frame.
1003  layer_name STRING,
1004  -- Frame's present type (eg. on time / early / late).
1005  present_type STRING,
1006  -- Whether the frame finishes on time.
1007  on_time_finish LONG,
1008  -- Whether the frame used gpu composition.
1009  gpu_composition LONG,
1010  -- Specify the jank types for this frame if there's jank, or none if no jank
1011  -- occurred.
1012  jank_type STRING,
1013  -- Severity of the jank: none if no jank.
1014  jank_severity_type STRING,
1015  -- Frame's prediction type (eg. valid / expired).
1016  prediction_type STRING,
1017  -- Jank tag based on jank type, used for slice visualization.
1018  jank_tag STRING
1019) AS
1020SELECT
1021  s.id,
1022  s.ts,
1023  s.dur,
1024  s.track_id,
1025  s.category,
1026  s.name,
1027  s.depth,
1028  s.parent_id,
1029  s.arg_set_id,
1030  extract_arg(s.arg_set_id, 'Display frame token') AS display_frame_token,
1031  extract_arg(s.arg_set_id, 'Surface frame token') AS surface_frame_token,
1032  t.upid,
1033  extract_arg(s.arg_set_id, 'Layer name') AS layer_name,
1034  extract_arg(s.arg_set_id, 'Present type') AS present_type,
1035  extract_arg(s.arg_set_id, 'On time finish') AS on_time_finish,
1036  extract_arg(s.arg_set_id, 'GPU composition') AS gpu_composition,
1037  extract_arg(s.arg_set_id, 'Jank type') AS jank_type,
1038  extract_arg(s.arg_set_id, 'Jank severity type') AS jank_severity_type,
1039  extract_arg(s.arg_set_id, 'Prediction type') AS prediction_type,
1040  extract_arg(s.arg_set_id, 'Jank tag') AS jank_tag
1041FROM slice AS s
1042JOIN process_track AS t
1043  ON s.track_id = t.id
1044WHERE
1045  t.type = 'android_actual_frame_timeline';
1046
1047-- Stores class information within ART heap graphs. It represents Java/Kotlin
1048-- classes that exist in the heap, including their names, inheritance
1049-- relationships, and loading context.
1050CREATE PERFETTO VIEW heap_graph_class (
1051  -- Unique identifier for this heap graph class.
1052  id ID,
1053  -- (potentially obfuscated) name of the class.
1054  name STRING,
1055  -- If class name was obfuscated and deobfuscation map for it provided, the
1056  -- deobfuscated name.
1057  deobfuscated_name STRING,
1058  -- the APK / Dex / JAR file the class is contained in.
1059  location STRING,
1060  -- The superclass of this class.
1061  superclass_id JOINID(heap_graph_class.id),
1062  -- The classloader that loaded this class.
1063  classloader_id LONG,
1064  -- The kind of class.
1065  kind STRING
1066) AS
1067SELECT
1068  id,
1069  name,
1070  deobfuscated_name,
1071  location,
1072  superclass_id,
1073  classloader_id,
1074  kind
1075FROM __intrinsic_heap_graph_class;
1076
1077-- The objects on the Dalvik heap.
1078--
1079-- All rows with the same (upid, graph_sample_ts) are one dump.
1080CREATE PERFETTO VIEW heap_graph_object (
1081  -- Unique identifier for this heap graph object.
1082  id ID,
1083  -- Unique PID of the target.
1084  upid JOINID(process.id),
1085  -- Timestamp this dump was taken at.
1086  graph_sample_ts TIMESTAMP,
1087  -- Size this object uses on the Java Heap.
1088  self_size LONG,
1089  -- Approximate amount of native memory used by this object, as reported by
1090  -- libcore.util.NativeAllocationRegistry.size.
1091  native_size LONG,
1092  -- Join key with heap_graph_reference containing all objects referred in this
1093  -- object's fields.
1094  reference_set_id JOINID(heap_graph_reference.id),
1095  -- Bool whether this object is reachable from a GC root. If false, this object
1096  -- is uncollected garbage.
1097  reachable BOOL,
1098  -- The type of ART heap this object is stored on (app, zygote, boot image)
1099  heap_type STRING,
1100  -- Class this object is an instance of.
1101  type_id JOINID(heap_graph_class.id),
1102  -- If not NULL, this object is a GC root.
1103  root_type STRING,
1104  -- Distance from the root object.
1105  root_distance LONG
1106) AS
1107SELECT
1108  id,
1109  upid,
1110  graph_sample_ts,
1111  self_size,
1112  native_size,
1113  reference_set_id,
1114  reachable,
1115  heap_type,
1116  type_id,
1117  root_type,
1118  root_distance
1119FROM __intrinsic_heap_graph_object;
1120
1121-- Many-to-many mapping between heap_graph_object.
1122--
1123-- This associates the object with given reference_set_id with the objects
1124-- that are referred to by its fields.
1125CREATE PERFETTO VIEW heap_graph_reference (
1126  -- Unique identifier for this heap graph reference.
1127  id ID,
1128  -- Join key to heap_graph_object.
1129  reference_set_id JOINID(heap_graph_object.id),
1130  -- Id of object that has this reference_set_id.
1131  owner_id JOINID(heap_graph_object.id),
1132  -- Id of object that is referred to.
1133  owned_id JOINID(heap_graph_object.id),
1134  -- The field that refers to the object. E.g. Foo.name.
1135  field_name STRING,
1136  -- The static type of the field. E.g. java.lang.String.
1137  field_type_name STRING,
1138  -- The deobfuscated name, if field_name was obfuscated and a deobfuscation
1139  -- mapping was provided for it.
1140  deobfuscated_field_name STRING
1141) AS
1142SELECT
1143  id,
1144  reference_set_id,
1145  owner_id,
1146  owned_id,
1147  field_name,
1148  field_type_name,
1149  deobfuscated_field_name
1150FROM __intrinsic_heap_graph_reference;
1151