blob: 4a05a74f67172aae2f7a69b083a539f04d59c632 [file] [log] [blame]
Primiano Tucci0e38a142019-01-07 20:51:09 +00001/*
2 * Copyright (C) 2019 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
Lalit Maganti7010b332020-02-07 10:51:15 +000017#ifndef SRC_TRACE_PROCESSOR_STORAGE_STATS_H_
18#define SRC_TRACE_PROCESSOR_STORAGE_STATS_H_
Primiano Tucci0e38a142019-01-07 20:51:09 +000019
Lalit Magantid54e5af2019-01-08 14:28:48 +000020#include <stddef.h>
21
Primiano Tucci0e38a142019-01-07 20:51:09 +000022namespace perfetto {
23namespace trace_processor {
24namespace stats {
25
26// Compile time list of parsing and processing stats.
27// clang-format off
Primiano Tuccib36e6242020-07-17 14:45:56 +020028#define PERFETTO_TP_STATS(F) \
29 F(android_log_num_failed, kSingle, kError, kTrace, ""), \
Hector Dearman8c6219d2020-08-17 16:26:23 +010030 F(android_log_num_skipped, kSingle, kInfo, kTrace, ""), \
Primiano Tuccib36e6242020-07-17 14:45:56 +020031 F(android_log_num_total, kSingle, kInfo, kTrace, ""), \
32 F(counter_events_out_of_order, kSingle, kError, kAnalysis, ""), \
Florian Mayer42cd5932020-11-02 16:02:43 +000033 F(deobfuscate_location_parse_error, kSingle, kError, kTrace, ""), \
Adithya Srinivasan526a34e2020-11-06 13:40:58 -080034 F(frame_timeline_event_parser_errors, kSingle, kInfo, kAnalysis, ""), \
35 F(ftrace_bundle_tokenizer_errors, kSingle, kError, kAnalysis, ""), \
Primiano Tuccib36e6242020-07-17 14:45:56 +020036 F(ftrace_cpu_bytes_read_begin, kIndexed, kInfo, kTrace, ""), \
37 F(ftrace_cpu_bytes_read_end, kIndexed, kInfo, kTrace, ""), \
38 F(ftrace_cpu_commit_overrun_begin, kIndexed, kError, kTrace, ""), \
39 F(ftrace_cpu_commit_overrun_end, kIndexed, kError, kTrace, ""), \
40 F(ftrace_cpu_dropped_events_begin, kIndexed, kError, kTrace, ""), \
41 F(ftrace_cpu_dropped_events_end, kIndexed, kError, kTrace, ""), \
42 F(ftrace_cpu_entries_begin, kIndexed, kInfo, kTrace, ""), \
43 F(ftrace_cpu_entries_end, kIndexed, kInfo, kTrace, ""), \
44 F(ftrace_cpu_now_ts_begin, kIndexed, kInfo, kTrace, ""), \
45 F(ftrace_cpu_now_ts_end, kIndexed, kInfo, kTrace, ""), \
46 F(ftrace_cpu_oldest_event_ts_begin, kIndexed, kInfo, kTrace, ""), \
47 F(ftrace_cpu_oldest_event_ts_end, kIndexed, kInfo, kTrace, ""), \
48 F(ftrace_cpu_overrun_begin, kIndexed, kInfo, kTrace, ""), \
49 F(ftrace_cpu_overrun_end, kIndexed, kDataLoss, kTrace, \
Ioannis Ilkos1e7e7f02020-05-26 14:32:28 +010050 "The kernel ftrace buffer cannot keep up with the rate of events " \
51 "produced. Indexed by CPU. This is likely a misconfiguration."), \
Primiano Tuccib36e6242020-07-17 14:45:56 +020052 F(ftrace_cpu_read_events_begin, kIndexed, kInfo, kTrace, ""), \
53 F(ftrace_cpu_read_events_end, kIndexed, kInfo, kTrace, ""), \
54 F(fuchsia_non_numeric_counters, kSingle, kError, kAnalysis, ""), \
55 F(fuchsia_timestamp_overflow, kSingle, kError, kAnalysis, ""), \
56 F(fuchsia_invalid_event, kSingle, kError, kAnalysis, ""), \
57 F(gpu_counters_invalid_spec, kSingle, kError, kAnalysis, ""), \
58 F(gpu_counters_missing_spec, kSingle, kError, kAnalysis, ""), \
59 F(gpu_render_stage_parser_errors, kSingle, kError, kAnalysis, ""), \
60 F(graphics_frame_event_parser_errors, kSingle, kInfo, kAnalysis, ""), \
61 F(guess_trace_type_duration_ns, kSingle, kInfo, kAnalysis, ""), \
62 F(interned_data_tokenizer_errors, kSingle, kInfo, kAnalysis, ""), \
63 F(invalid_clock_snapshots, kSingle, kError, kAnalysis, ""), \
64 F(invalid_cpu_times, kSingle, kError, kAnalysis, ""), \
65 F(meminfo_unknown_keys, kSingle, kError, kAnalysis, ""), \
66 F(mismatched_sched_switch_tids, kSingle, kError, kAnalysis, ""), \
67 F(mm_unknown_type, kSingle, kError, kAnalysis, ""), \
68 F(parse_trace_duration_ns, kSingle, kInfo, kAnalysis, ""), \
69 F(power_rail_unknown_index, kSingle, kError, kTrace, ""), \
70 F(proc_stat_unknown_counters, kSingle, kError, kAnalysis, ""), \
71 F(rss_stat_unknown_keys, kSingle, kError, kAnalysis, ""), \
72 F(rss_stat_negative_size, kSingle, kInfo, kAnalysis, ""), \
73 F(rss_stat_unknown_thread_for_mm_id, kSingle, kInfo, kAnalysis, ""), \
74 F(sched_switch_out_of_order, kSingle, kError, kAnalysis, ""), \
75 F(slice_out_of_order, kSingle, kError, kAnalysis, ""), \
Andrii041f1e82020-07-29 17:40:09 +030076 F(flow_duplicate_id, kSingle, kError, kTrace, ""), \
77 F(flow_no_enclosing_slice, kSingle, kError, kTrace, ""), \
78 F(flow_step_without_start, kSingle, kInfo, kTrace, ""), \
79 F(flow_end_without_start, kSingle, kInfo, kTrace, ""), \
80 F(flow_invalid_id, kSingle, kError, kTrace, ""), \
81 F(flow_without_direction, kSingle, kError, kTrace, ""), \
Primiano Tuccib36e6242020-07-17 14:45:56 +020082 F(stackprofile_invalid_string_id, kSingle, kError, kTrace, ""), \
83 F(stackprofile_invalid_mapping_id, kSingle, kError, kTrace, ""), \
84 F(stackprofile_invalid_frame_id, kSingle, kError, kTrace, ""), \
85 F(stackprofile_invalid_callstack_id, kSingle, kError, kTrace, ""), \
86 F(stackprofile_parser_error, kSingle, kError, kTrace, ""), \
87 F(systrace_parse_failure, kSingle, kError, kAnalysis, ""), \
88 F(task_state_invalid, kSingle, kError, kAnalysis, ""), \
89 F(traced_buf_buffer_size, kIndexed, kInfo, kTrace, ""), \
90 F(traced_buf_bytes_overwritten, kIndexed, kInfo, kTrace, ""), \
91 F(traced_buf_bytes_read, kIndexed, kInfo, kTrace, ""), \
92 F(traced_buf_bytes_written, kIndexed, kInfo, kTrace, ""), \
93 F(traced_buf_chunks_discarded, kIndexed, kInfo, kTrace, ""), \
94 F(traced_buf_chunks_overwritten, kIndexed, kInfo, kTrace, ""), \
95 F(traced_buf_chunks_read, kIndexed, kInfo, kTrace, ""), \
96 F(traced_buf_chunks_rewritten, kIndexed, kInfo, kTrace, ""), \
97 F(traced_buf_chunks_written, kIndexed, kInfo, kTrace, ""), \
98 F(traced_buf_chunks_committed_out_of_order, \
99 kIndexed, kInfo, kTrace, ""), \
100 F(traced_buf_padding_bytes_cleared, kIndexed, kInfo, kTrace, ""), \
101 F(traced_buf_padding_bytes_written, kIndexed, kInfo, kTrace, ""), \
Eric Secklerd4d1ddf2021-04-30 15:10:22 +0000102 F(traced_buf_patches_failed, kIndexed, kDataLoss, kTrace, ""), \
Primiano Tuccib36e6242020-07-17 14:45:56 +0200103 F(traced_buf_patches_succeeded, kIndexed, kInfo, kTrace, ""), \
104 F(traced_buf_readaheads_failed, kIndexed, kInfo, kTrace, ""), \
105 F(traced_buf_readaheads_succeeded, kIndexed, kInfo, kTrace, ""), \
Eric Secklerd4d1ddf2021-04-30 15:10:22 +0000106 F(traced_buf_trace_writer_packet_loss,kIndexed, kDataLoss, kTrace, ""), \
Primiano Tuccib36e6242020-07-17 14:45:56 +0200107 F(traced_buf_write_wrap_count, kIndexed, kInfo, kTrace, ""), \
108 F(traced_chunks_discarded, kSingle, kInfo, kTrace, ""), \
109 F(traced_data_sources_registered, kSingle, kInfo, kTrace, ""), \
110 F(traced_data_sources_seen, kSingle, kInfo, kTrace, ""), \
111 F(traced_patches_discarded, kSingle, kInfo, kTrace, ""), \
112 F(traced_producers_connected, kSingle, kInfo, kTrace, ""), \
113 F(traced_producers_seen, kSingle, kInfo, kTrace, ""), \
114 F(traced_total_buffers, kSingle, kInfo, kTrace, ""), \
115 F(traced_tracing_sessions, kSingle, kInfo, kTrace, ""), \
116 F(track_event_parser_errors, kSingle, kInfo, kAnalysis, ""), \
117 F(track_event_tokenizer_errors, kSingle, kInfo, kAnalysis, ""), \
118 F(tokenizer_skipped_packets, kSingle, kInfo, kAnalysis, ""), \
119 F(vmstat_unknown_keys, kSingle, kError, kAnalysis, ""), \
120 F(vulkan_allocations_invalid_string_id, \
121 kSingle, kError, kTrace, ""), \
122 F(clock_sync_failure, kSingle, kError, kAnalysis, ""), \
123 F(clock_sync_cache_miss, kSingle, kInfo, kAnalysis, ""), \
124 F(process_tracker_errors, kSingle, kError, kAnalysis, ""), \
125 F(json_tokenizer_failure, kSingle, kError, kTrace, ""), \
Lalit Maganti0732e002021-03-10 17:05:18 +0000126 F(json_parser_failure, kSingle, kError, kTrace, ""), \
Lalit Magantib5072a92021-06-01 14:32:50 +0100127 F(json_display_time_unit_too_late, kSingle, kError, kTrace, \
128 "The displayTimeUnit key came too late in the JSON trace so was " \
129 "ignored. Trace processor only supports displayTimeUnit appearing " \
130 "at the start of JSON traces"), \
Primiano Tuccib36e6242020-07-17 14:45:56 +0200131 F(heap_graph_invalid_string_id, kIndexed, kError, kTrace, ""), \
132 F(heap_graph_non_finalized_graph, kSingle, kError, kTrace, ""), \
133 F(heap_graph_malformed_packet, kIndexed, kError, kTrace, ""), \
134 F(heap_graph_missing_packet, kIndexed, kError, kTrace, ""), \
Primiano Tuccib36e6242020-07-17 14:45:56 +0200135 F(heapprofd_buffer_corrupted, kIndexed, kError, kTrace, \
Primiano Tuccia6624852020-05-21 19:12:50 +0100136 "Shared memory buffer corrupted. This is a bug or memory corruption " \
137 "in the target. Indexed by target upid."), \
Primiano Tuccib36e6242020-07-17 14:45:56 +0200138 F(heapprofd_hit_guardrail, kIndexed, kError, kTrace, \
Primiano Tuccia6624852020-05-21 19:12:50 +0100139 "HeapprofdConfig specified a CPU or Memory Guardrail that was hit. " \
140 "Indexed by target upid."), \
Primiano Tuccib36e6242020-07-17 14:45:56 +0200141 F(heapprofd_buffer_overran, kIndexed, kDataLoss, kTrace, \
Primiano Tuccia6624852020-05-21 19:12:50 +0100142 "The shared memory buffer between the target and heapprofd overran. " \
143 "The profile was truncated early. Indexed by target upid."), \
Florian Mayer2069fab2021-02-24 11:28:00 +0000144 F(heapprofd_client_error, kIndexed, kError, kTrace, \
145 "The heapprofd client ran into a problem and disconnected. " \
146 "See profile_packet.proto for error codes."), \
Primiano Tuccib36e6242020-07-17 14:45:56 +0200147 F(heapprofd_client_disconnected, kIndexed, kInfo, kTrace, ""), \
148 F(heapprofd_malformed_packet, kIndexed, kError, kTrace, ""), \
149 F(heapprofd_missing_packet, kSingle, kError, kTrace, ""), \
150 F(heapprofd_rejected_concurrent, kIndexed, kError, kTrace, \
Primiano Tuccia6624852020-05-21 19:12:50 +0100151 "The target was already profiled by another tracing session, so the " \
Primiano Tuccib36e6242020-07-17 14:45:56 +0200152 "profile was not taken. Indexed by target upid."), \
153 F(heapprofd_non_finalized_profile, kSingle, kError, kTrace, ""), \
Florian Mayer5b17cd42021-01-29 12:41:31 +0000154 F(heapprofd_sampling_interval_adjusted, \
155 kIndexed, kInfo, kTrace, \
156 "By how many byes the interval for PID was increased " \
157 "by adaptive sampling."), \
Florian Mayera67f9ec2021-03-29 16:30:14 +0100158 F(heapprofd_unwind_time_us, kIndexed, kInfo, kTrace, \
159 "Time spent unwinding callstacks."), \
160 F(heapprofd_unwind_samples, kIndexed, kInfo, kTrace, \
161 "Number of samples unwound."), \
Florian Mayeraf4d1142021-04-13 18:39:31 +0100162 F(heapprofd_client_spinlock_blocked, kIndexed, kInfo, kTrace, \
163 "Time (us) the heapprofd client was blocked on the spinlock."), \
Florian Mayera7b53eb2021-05-13 13:34:09 +0100164 F(heapprofd_last_profile_timestamp, kIndexed, kInfo, kTrace, \
165 "The timestamp (in trace time) for the last dump for a process"), \
Primiano Tuccib36e6242020-07-17 14:45:56 +0200166 F(metatrace_overruns, kSingle, kError, kTrace, ""), \
167 F(packages_list_has_parse_errors, kSingle, kError, kTrace, ""), \
168 F(packages_list_has_read_errors, kSingle, kError, kTrace, ""), \
169 F(compact_sched_has_parse_errors, kSingle, kError, kTrace, ""), \
170 F(misplaced_end_event, kSingle, kDataLoss, kAnalysis, ""), \
171 F(sched_waking_out_of_order, kSingle, kError, kAnalysis, ""), \
172 F(compact_sched_switch_skipped, kSingle, kInfo, kAnalysis, ""), \
173 F(compact_sched_waking_skipped, kSingle, kInfo, kAnalysis, ""), \
174 F(empty_chrome_metadata, kSingle, kError, kTrace, ""), \
175 F(perf_cpu_lost_records, kIndexed, kDataLoss, kTrace, ""), \
176 F(ninja_parse_errors, kSingle, kError, kTrace, ""), \
177 F(perf_samples_skipped, kSingle, kInfo, kTrace, ""), \
178 F(perf_samples_skipped_dataloss, kSingle, kDataLoss, kTrace, ""), \
Sylwester Blaszczyk76aa7002020-11-27 15:48:21 +0100179 F(memory_snapshot_parser_failure, kSingle, kError, kAnalysis, ""), \
Primiano Tuccib36e6242020-07-17 14:45:56 +0200180 F(thread_time_in_state_out_of_order, kSingle, kError, kAnalysis, ""), \
181 F(thread_time_in_state_unknown_cpu_freq, \
Lalit Maganti00c86672020-07-17 16:38:17 +0100182 kSingle, kError, kAnalysis, ""), \
183 F(ftrace_packet_before_tracing_start, kSingle, kInfo, kAnalysis, \
184 "An ftrace packet was seen before the tracing start timestamp from " \
185 "the tracing service. This happens if the ftrace buffers were not " \
186 "cleared properly. These packets are silently dropped by trace " \
Ryan Savitski310f4bf2021-04-08 15:13:12 +0100187 "processor."), \
188 F(perf_guardrail_stop_ts, kIndexed, kDataLoss, kTrace, "")
Primiano Tucci0e38a142019-01-07 20:51:09 +0000189// clang-format on
190
191enum Type {
192 kSingle, // Single-value property, one value per key.
193 kIndexed // Indexed property, multiple value per key (e.g. cpu_stats[1]).
194};
195
196enum Severity {
Ioannis Ilkos5e79b8a2019-05-23 18:09:54 +0100197 kInfo, // Diagnostic counters
198 kDataLoss, // Correct operation that still resulted in data loss
Florian Mayer8d2b5932020-01-30 10:50:11 +0000199 kError // If any kError counter is > 0 trace_processor_shell will
200 // raise an error. This is *not* surfaced in the web UI.
Hector Dearman7dbfa1c2021-01-15 14:01:26 +0000201 // TODO(b/148587181): Surface these errors in the UI.
Primiano Tucci0e38a142019-01-07 20:51:09 +0000202};
203
204enum Source {
205 // The counter is collected when recording the trace on-device and is just
206 // being reflected in the stats table.
207 kTrace,
208
209 // The counter is genrated when importing / processing the trace in the trace
210 // processor.
211 kAnalysis
212};
213
Sami Kyostila1c76dff2020-01-15 16:32:21 +0000214// Ignore GCC warning about a missing argument for a variadic macro parameter.
Primiano Tucci63201702020-12-04 17:38:12 +0100215#if defined(__GNUC__) || defined(__clang__)
Sami Kyostila1c76dff2020-01-15 16:32:21 +0000216#pragma GCC system_header
Primiano Tucci63201702020-12-04 17:38:12 +0100217#endif
Sami Kyostila1c76dff2020-01-15 16:32:21 +0000218
Primiano Tucci0e38a142019-01-07 20:51:09 +0000219// Declares an enum of literals (one for each stat). The enum values of each
220// literal corresponds to the string index in the arrays below.
221#define PERFETTO_TP_STATS_ENUM(name, ...) name
222enum KeyIDs : size_t { PERFETTO_TP_STATS(PERFETTO_TP_STATS_ENUM), kNumKeys };
223
224// The code below declares an array for each property (name, type, ...).
225
226#define PERFETTO_TP_STATS_NAME(name, ...) #name
227constexpr char const* kNames[] = {PERFETTO_TP_STATS(PERFETTO_TP_STATS_NAME)};
228
229#define PERFETTO_TP_STATS_TYPE(_, type, ...) type
230constexpr Type kTypes[] = {PERFETTO_TP_STATS(PERFETTO_TP_STATS_TYPE)};
231
232#define PERFETTO_TP_STATS_SEVERITY(_, __, severity, ...) severity
233constexpr Severity kSeverities[] = {
234 PERFETTO_TP_STATS(PERFETTO_TP_STATS_SEVERITY)};
235
236#define PERFETTO_TP_STATS_SOURCE(_, __, ___, source, ...) source
237constexpr Source kSources[] = {PERFETTO_TP_STATS(PERFETTO_TP_STATS_SOURCE)};
238
Primiano Tuccib36e6242020-07-17 14:45:56 +0200239#define PERFETTO_TP_STATS_DESCRIPTION(_, __, ___, ____, descr, ...) descr
240constexpr char const* kDescriptions[] = {
241 PERFETTO_TP_STATS(PERFETTO_TP_STATS_DESCRIPTION)};
242
Primiano Tucci0e38a142019-01-07 20:51:09 +0000243} // namespace stats
244} // namespace trace_processor
245} // namespace perfetto
246
Lalit Maganti7010b332020-02-07 10:51:15 +0000247#endif // SRC_TRACE_PROCESSOR_STORAGE_STATS_H_