• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2017 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
19import "protos/perfetto/common/trace_stats.proto";
20import "protos/perfetto/config/trace_config.proto";
21import "protos/perfetto/trace/extension_descriptor.proto";
22import "protos/perfetto/trace/android/android_log.proto";
23import "protos/perfetto/trace/android/android_system_property.proto";
24import "protos/perfetto/trace/android/camera_event.proto";
25import "protos/perfetto/trace/android/frame_timeline_event.proto";
26import "protos/perfetto/trace/android/gpu_mem_event.proto";
27import "protos/perfetto/trace/android/graphics_frame_event.proto";
28import "protos/perfetto/trace/android/initial_display_state.proto";
29import "protos/perfetto/trace/android/packages_list.proto";
30import "protos/perfetto/trace/chrome/chrome_benchmark_metadata.proto";
31import "protos/perfetto/trace/chrome/chrome_metadata.proto";
32import "protos/perfetto/trace/chrome/chrome_trace_event.proto";
33import "protos/perfetto/trace/clock_snapshot.proto";
34import "protos/perfetto/trace/filesystem/inode_file_map.proto";
35import "protos/perfetto/trace/ftrace/ftrace_event_bundle.proto";
36import "protos/perfetto/trace/ftrace/ftrace_stats.proto";
37import "protos/perfetto/trace/gpu/gpu_counter_event.proto";
38import "protos/perfetto/trace/gpu/gpu_log.proto";
39import "protos/perfetto/trace/gpu/gpu_render_stage_event.proto";
40import "protos/perfetto/trace/gpu/vulkan_memory_event.proto";
41import "protos/perfetto/trace/gpu/vulkan_api_event.proto";
42import "protos/perfetto/trace/interned_data/interned_data.proto";
43import "protos/perfetto/trace/memory_graph.proto";
44import "protos/perfetto/trace/perfetto/perfetto_metatrace.proto";
45import "protos/perfetto/trace/perfetto/tracing_service_event.proto";
46import "protos/perfetto/trace/power/android_energy_estimation_breakdown.proto";
47import "protos/perfetto/trace/power/battery_counters.proto";
48import "protos/perfetto/trace/power/power_rails.proto";
49import "protos/perfetto/trace/profiling/deobfuscation.proto";
50import "protos/perfetto/trace/profiling/heap_graph.proto";
51import "protos/perfetto/trace/profiling/profile_common.proto";
52import "protos/perfetto/trace/profiling/profile_packet.proto";
53import "protos/perfetto/trace/profiling/smaps.proto";
54import "protos/perfetto/trace/ps/process_stats.proto";
55import "protos/perfetto/trace/ps/process_tree.proto";
56import "protos/perfetto/trace/sys_stats/sys_stats.proto";
57import "protos/perfetto/trace/system_info.proto";
58import "protos/perfetto/trace/system_info/cpu_info.proto";
59import "protos/perfetto/trace/trace_packet_defaults.proto";
60import "protos/perfetto/trace/track_event/process_descriptor.proto";
61import "protos/perfetto/trace/track_event/thread_descriptor.proto";
62import "protos/perfetto/trace/track_event/track_descriptor.proto";
63import "protos/perfetto/trace/track_event/track_event.proto";
64import "protos/perfetto/trace/translation/translation_table.proto";
65import "protos/perfetto/trace/trigger.proto";
66import "protos/perfetto/trace/test_event.proto";
67import "protos/perfetto/trace/ui_state.proto";
68
69package perfetto.protos;
70
71// TracePacket is the root object of a Perfeto trace.
72// A Perfetto trace is a linear sequence of TracePacket(s).
73//
74// The tracing service guarantees that all TracePacket(s) written by a given
75// TraceWriter are seen in-order, without gaps or duplicates. If, for any
76// reason, a TraceWriter sequence becomes invalid, no more packets are returned
77// to the Consumer (or written into the trace file).
78// TracePacket(s) written by different TraceWriter(s), hence even different
79// data sources, can be seen in arbitrary order.
80// The consumer can re-establish a total order, if interested, using the packet
81// timestamps, after having synchronized the different clocks onto a global
82// clock.
83//
84// The tracing service is agnostic of the content of TracePacket, with the
85// exception of few fields (e.g.. trusted_*, trace_config) that are written by
86// the service itself.
87//
88// See the [Buffers and Dataflow](/docs/concepts/buffers.md) doc for details.
89//
90// Next reserved id: 14 (up to 15).
91// Next id: 86.
92message TracePacket {
93  // The timestamp of the TracePacket.
94  // By default this timestamps refers to the trace clock (CLOCK_BOOTTIME on
95  // Android). It can be overridden using a different timestamp_clock_id.
96  // The clock domain definition in ClockSnapshot can also override:
97  // - The unit (default: 1ns).
98  // - The absolute vs delta encoding (default: absolute timestamp).
99  optional uint64 timestamp = 8;
100
101  // Specifies the ID of the clock used for the TracePacket |timestamp|. Can be
102  // one of the built-in types from ClockSnapshot::BuiltinClocks, or a
103  // producer-defined clock id.
104  // If unspecified and if no default per-sequence value has been provided via
105  // TracePacketDefaults, it defaults to BuiltinClocks::BOOTTIME.
106  optional uint32 timestamp_clock_id = 58;
107
108  oneof data {
109    ProcessTree process_tree = 2;
110    ProcessStats process_stats = 9;
111    InodeFileMap inode_file_map = 4;
112    ChromeEventBundle chrome_events = 5;
113    ClockSnapshot clock_snapshot = 6;
114    SysStats sys_stats = 7;
115    TrackEvent track_event = 11;
116
117    // IDs up to 15 are reserved. They take only one byte to encode their
118    // preamble so should be used for frequent events.
119
120    TraceConfig trace_config = 33;
121    FtraceStats ftrace_stats = 34;
122    TraceStats trace_stats = 35;
123    ProfilePacket profile_packet = 37;
124    StreamingAllocation streaming_allocation = 74;
125    StreamingFree streaming_free = 75;
126    BatteryCounters battery = 38;
127    PowerRails power_rails = 40;
128    AndroidLogPacket android_log = 39;
129    SystemInfo system_info = 45;
130    Trigger trigger = 46;
131    PackagesList packages_list = 47;
132    ChromeBenchmarkMetadata chrome_benchmark_metadata = 48;
133    PerfettoMetatrace perfetto_metatrace = 49;
134    ChromeMetadataPacket chrome_metadata = 51;
135    GpuCounterEvent gpu_counter_event = 52;
136    GpuRenderStageEvent gpu_render_stage_event = 53;
137    StreamingProfilePacket streaming_profile_packet = 54;
138    HeapGraph heap_graph = 56;
139    GraphicsFrameEvent graphics_frame_event = 57;
140    VulkanMemoryEvent vulkan_memory_event = 62;
141    GpuLog gpu_log = 63;
142    VulkanApiEvent vulkan_api_event = 65;
143    PerfSample perf_sample = 66;
144    CpuInfo cpu_info = 67;
145    SmapsPacket smaps_packet = 68;
146    TracingServiceEvent service_event = 69;
147    InitialDisplayState initial_display_state = 70;
148    GpuMemTotalEvent gpu_mem_total_event = 71;
149    MemoryTrackerSnapshot memory_tracker_snapshot = 73;
150    FrameTimelineEvent frame_timeline_event = 76;
151    AndroidEnergyEstimationBreakdown android_energy_estimation_breakdown = 77;
152    UiState ui_state = 78;
153    AndroidCameraFrameEvent android_camera_frame_event = 80;
154    AndroidCameraSessionStats android_camera_session_stats = 81;
155    TranslationTable translation_table = 82;
156    AndroidSystemProperty android_system_property = 86;
157
158    // Only used in profile packets.
159    ProfiledFrameSymbols profiled_frame_symbols = 55;
160    ModuleSymbols module_symbols = 61;
161    DeobfuscationMapping deobfuscation_mapping = 64;
162
163    // Only used by TrackEvent.
164    TrackDescriptor track_descriptor = 60;
165
166    // Deprecated, use TrackDescriptor instead.
167    ProcessDescriptor process_descriptor = 43;
168
169    // Deprecated, use TrackDescriptor instead.
170    ThreadDescriptor thread_descriptor = 44;
171
172    // Events from the Linux kernel ftrace infrastructure.
173    FtraceEventBundle ftrace_events = 1;
174
175    // This field is emitted at periodic intervals (~10s) and
176    // contains always the binary representation of the UUID
177    // {82477a76-b28d-42ba-81dc-33326d57a079}. This is used to be able to
178    // efficiently partition long traces without having to fully parse them.
179    bytes synchronization_marker = 36;
180
181    // Zero or more proto encoded trace packets compressed using deflate.
182    // Each compressed_packets TracePacket (including the two field ids and
183    // sizes) should be less than 512KB.
184    bytes compressed_packets = 50;
185
186    // Data sources can extend the trace proto with custom extension protos (see
187    // docs/design-docs/extensions.md). When they do that, the descriptor of
188    // their extension proto descriptor is serialized in this packet. This
189    // allows trace_processor to deserialize extended messages using reflection
190    // even if the extension proto is not checked in the Perfetto repo.
191    ExtensionDescriptor extension_descriptor = 72;
192
193    // This field is only used for testing.
194    // In previous versions of this proto this field had the id 268435455
195    // This caused many problems:
196    // - protozero decoder does not handle field ids larger than 999.
197    // - old versions of protoc produce Java bindings with syntax errors when
198    //   the field id is large enough.
199    TestEvent for_testing = 900;
200  }
201
202  // Trusted user id of the producer which generated this packet. Keep in sync
203  // with TrustedPacket.trusted_uid.
204  //
205  // TODO(eseckler): Emit this field in a PacketSequenceDescriptor message
206  // instead.
207  oneof optional_trusted_uid { int32 trusted_uid = 3; };
208
209  // Service-assigned identifier of the packet sequence this packet belongs to.
210  // Uniquely identifies a producer + writer pair within the tracing session. A
211  // value of zero denotes an invalid ID. Keep in sync with
212  // TrustedPacket.trusted_packet_sequence_id.
213  oneof optional_trusted_packet_sequence_id {
214    uint32 trusted_packet_sequence_id = 10;
215  }
216
217  // Trusted process id of the producer which generated this packet, written by
218  // the service.
219  optional int32 trusted_pid = 79;
220
221  // Incrementally emitted interned data, valid only on the packet's sequence
222  // (packets with the same |trusted_packet_sequence_id|). The writer will
223  // usually emit new interned data in the same TracePacket that first refers to
224  // it (since the last reset of interning state). It may also be emitted
225  // proactively in advance of referring to them in later packets.
226  optional InternedData interned_data = 12;
227
228  enum SequenceFlags {
229    SEQ_UNSPECIFIED = 0;
230
231    // Set by the writer to indicate that it will re-emit any incremental data
232    // for the packet's sequence before referring to it again. This includes
233    // interned data as well as periodically emitted data like
234    // Process/ThreadDescriptors. This flag only affects the current packet
235    // sequence (see |trusted_packet_sequence_id|).
236    //
237    // When set, this TracePacket and subsequent TracePackets on the same
238    // sequence will not refer to any incremental data emitted before this
239    // TracePacket. For example, previously emitted interned data will be
240    // re-emitted if it is referred to again.
241    //
242    // When the reader detects packet loss (|previous_packet_dropped|), it needs
243    // to skip packets in the sequence until the next one with this flag set, to
244    // ensure intact incremental data.
245    SEQ_INCREMENTAL_STATE_CLEARED = 1;
246
247    // This packet requires incremental state, such as TracePacketDefaults or
248    // InternedData, to be parsed correctly. The trace reader should skip this
249    // packet if incremental state is not valid on this sequence, i.e. if no
250    // packet with the SEQ_INCREMENTAL_STATE_CLEARED flag has been seen on the
251    // current |trusted_packet_sequence_id|.
252    SEQ_NEEDS_INCREMENTAL_STATE = 2;
253  };
254  optional uint32 sequence_flags = 13;
255
256  // DEPRECATED. Moved to SequenceFlags::SEQ_INCREMENTAL_STATE_CLEARED.
257  optional bool incremental_state_cleared = 41;
258
259  // Default values for fields of later TracePackets emitted on this packet's
260  // sequence (TracePackets with the same |trusted_packet_sequence_id|).
261  // It must be reemitted when incremental state is cleared (see
262  // |incremental_state_cleared|).
263  // Requires that any future packet emitted on the same sequence specifies
264  // the SEQ_NEEDS_INCREMENTAL_STATE flag.
265  // TracePacketDefaults always override the global defaults for any future
266  // packet on this sequence (regardless of SEQ_NEEDS_INCREMENTAL_STATE).
267  optional TracePacketDefaults trace_packet_defaults = 59;
268
269  // Flag set by the service if, for the current packet sequence (see
270  // |trusted_packet_sequence_id|), either:
271  // * this is the first packet, or
272  // * one or multiple packets were dropped since the last packet that the
273  //   consumer read from the sequence. This can happen if chunks in the trace
274  //   buffer are overridden before the consumer could read them when the trace
275  //   is configured in ring buffer mode.
276  //
277  // When packet loss occurs, incrementally emitted data (including interned
278  // data) on the sequence should be considered invalid up until the next packet
279  // with SEQ_INCREMENTAL_STATE_CLEARED set.
280  optional bool previous_packet_dropped = 42;
281}
282