1 /* 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 17 #ifndef SRC_TRACE_PROCESSOR_STORAGE_STATS_H_ 18 #define SRC_TRACE_PROCESSOR_STORAGE_STATS_H_ 19 20 #include <stddef.h> 21 22 namespace perfetto { 23 namespace trace_processor { 24 namespace stats { 25 26 // Compile time list of parsing and processing stats. 27 // clang-format off 28 #define PERFETTO_TP_STATS(F) \ 29 F(android_br_parse_errors, kSingle, kError, kTrace, ""), \ 30 F(android_log_num_failed, kSingle, kError, kTrace, ""), \ 31 F(android_log_format_invalid, kSingle, kError, kTrace, ""), \ 32 F(android_log_num_skipped, kSingle, kInfo, kTrace, ""), \ 33 F(android_log_num_total, kSingle, kInfo, kTrace, ""), \ 34 F(counter_events_out_of_order, kSingle, kError, kAnalysis, ""), \ 35 F(deobfuscate_location_parse_error, kSingle, kError, kTrace, ""), \ 36 F(energy_breakdown_missing_values, kSingle, kError, kAnalysis, ""), \ 37 F(energy_descriptor_invalid, kSingle, kError, kAnalysis, ""), \ 38 F(entity_state_descriptor_invalid, kSingle, kError, kAnalysis, ""), \ 39 F(entity_state_residency_invalid, kSingle, kError, kAnalysis, ""), \ 40 F(entity_state_residency_lookup_failed, kSingle, kError, kAnalysis, ""), \ 41 F(energy_uid_breakdown_missing_values, kSingle, kError, kAnalysis, ""), \ 42 F(frame_timeline_event_parser_errors, kSingle, kInfo, kAnalysis, ""), \ 43 F(frame_timeline_unpaired_end_event, kSingle, kInfo, kAnalysis, ""), \ 44 F(ftrace_bundle_tokenizer_errors, kSingle, kError, kAnalysis, ""), \ 45 F(ftrace_cpu_bytes_read_begin, kIndexed, kInfo, kTrace, ""), \ 46 F(ftrace_cpu_bytes_read_end, kIndexed, kInfo, kTrace, ""), \ 47 F(ftrace_cpu_bytes_read_delta, kIndexed, kInfo, kTrace, ""), \ 48 F(ftrace_cpu_commit_overrun_begin, kIndexed, kInfo, kTrace, ""), \ 49 F(ftrace_cpu_commit_overrun_end, kIndexed, kInfo, kTrace, ""), \ 50 F(ftrace_cpu_commit_overrun_delta, kIndexed, kError, kTrace, ""), \ 51 F(ftrace_cpu_dropped_events_begin, kIndexed, kInfo, kTrace, ""), \ 52 F(ftrace_cpu_dropped_events_end, kIndexed, kInfo, kTrace, ""), \ 53 F(ftrace_cpu_dropped_events_delta, kIndexed, kError, kTrace, ""), \ 54 F(ftrace_cpu_entries_begin, kIndexed, kInfo, kTrace, ""), \ 55 F(ftrace_cpu_entries_end, kIndexed, kInfo, kTrace, ""), \ 56 F(ftrace_cpu_entries_delta, kIndexed, kInfo, kTrace, ""), \ 57 F(ftrace_cpu_now_ts_begin, kIndexed, kInfo, kTrace, ""), \ 58 F(ftrace_cpu_now_ts_end, kIndexed, kInfo, kTrace, ""), \ 59 F(ftrace_cpu_oldest_event_ts_begin, kIndexed, kInfo, kTrace, ""), \ 60 F(ftrace_cpu_oldest_event_ts_end, kIndexed, kInfo, kTrace, ""), \ 61 F(ftrace_cpu_overrun_begin, kIndexed, kInfo, kTrace, ""), \ 62 F(ftrace_cpu_overrun_end, kIndexed, kInfo, kTrace, ""), \ 63 F(ftrace_cpu_overrun_delta, kIndexed, kDataLoss, kTrace, \ 64 "The kernel ftrace buffer cannot keep up with the rate of events " \ 65 "produced. Indexed by CPU. This is likely a misconfiguration."), \ 66 F(ftrace_cpu_read_events_begin, kIndexed, kInfo, kTrace, ""), \ 67 F(ftrace_cpu_read_events_end, kIndexed, kInfo, kTrace, ""), \ 68 F(ftrace_cpu_read_events_delta, kIndexed, kInfo, kTrace, ""), \ 69 F(ftrace_setup_errors, kSingle, kInfo, kTrace, \ 70 "One or more atrace/ftrace categories were not found or failed to enable. " \ 71 "See ftrace_setup_errors in the metadata table for more details."), \ 72 F(fuchsia_non_numeric_counters, kSingle, kError, kAnalysis, ""), \ 73 F(fuchsia_timestamp_overflow, kSingle, kError, kAnalysis, ""), \ 74 F(fuchsia_invalid_event, kSingle, kError, kAnalysis, ""), \ 75 F(gpu_counters_invalid_spec, kSingle, kError, kAnalysis, ""), \ 76 F(gpu_counters_missing_spec, kSingle, kError, kAnalysis, ""), \ 77 F(gpu_render_stage_parser_errors, kSingle, kError, kAnalysis, ""), \ 78 F(graphics_frame_event_parser_errors, kSingle, kInfo, kAnalysis, ""), \ 79 F(guess_trace_type_duration_ns, kSingle, kInfo, kAnalysis, ""), \ 80 F(interned_data_tokenizer_errors, kSingle, kInfo, kAnalysis, ""), \ 81 F(invalid_clock_snapshots, kSingle, kError, kAnalysis, ""), \ 82 F(invalid_cpu_times, kSingle, kError, kAnalysis, ""), \ 83 F(meminfo_unknown_keys, kSingle, kError, kAnalysis, ""), \ 84 F(mismatched_sched_switch_tids, kSingle, kError, kAnalysis, ""), \ 85 F(mm_unknown_type, kSingle, kError, kAnalysis, ""), \ 86 F(parse_trace_duration_ns, kSingle, kInfo, kAnalysis, ""), \ 87 F(power_rail_unknown_index, kSingle, kError, kTrace, ""), \ 88 F(proc_stat_unknown_counters, kSingle, kError, kAnalysis, ""), \ 89 F(rss_stat_unknown_keys, kSingle, kError, kAnalysis, ""), \ 90 F(rss_stat_negative_size, kSingle, kInfo, kAnalysis, ""), \ 91 F(rss_stat_unknown_thread_for_mm_id, kSingle, kInfo, kAnalysis, ""), \ 92 F(sched_switch_out_of_order, kSingle, kError, kAnalysis, ""), \ 93 F(slice_out_of_order, kSingle, kError, kAnalysis, ""), \ 94 F(flow_duplicate_id, kSingle, kError, kTrace, ""), \ 95 F(flow_no_enclosing_slice, kSingle, kError, kTrace, ""), \ 96 F(flow_step_without_start, kSingle, kInfo, kTrace, ""), \ 97 F(flow_end_without_start, kSingle, kInfo, kTrace, ""), \ 98 F(flow_invalid_id, kSingle, kError, kTrace, ""), \ 99 F(flow_without_direction, kSingle, kError, kTrace, ""), \ 100 F(stackprofile_invalid_string_id, kSingle, kError, kTrace, ""), \ 101 F(stackprofile_invalid_mapping_id, kSingle, kError, kTrace, ""), \ 102 F(stackprofile_invalid_frame_id, kSingle, kError, kTrace, ""), \ 103 F(stackprofile_invalid_callstack_id, kSingle, kError, kTrace, ""), \ 104 F(stackprofile_parser_error, kSingle, kError, kTrace, ""), \ 105 F(systrace_parse_failure, kSingle, kError, kAnalysis, ""), \ 106 F(task_state_invalid, kSingle, kError, kAnalysis, ""), \ 107 F(traced_buf_abi_violations, kIndexed, kDataLoss, kTrace, ""), \ 108 F(traced_buf_buffer_size, kIndexed, kInfo, kTrace, ""), \ 109 F(traced_buf_bytes_overwritten, kIndexed, kInfo, kTrace, ""), \ 110 F(traced_buf_bytes_read, kIndexed, kInfo, kTrace, ""), \ 111 F(traced_buf_bytes_written, kIndexed, kInfo, kTrace, ""), \ 112 F(traced_buf_chunks_discarded, kIndexed, kInfo, kTrace, ""), \ 113 F(traced_buf_chunks_overwritten, kIndexed, kInfo, kTrace, ""), \ 114 F(traced_buf_chunks_read, kIndexed, kInfo, kTrace, ""), \ 115 F(traced_buf_chunks_rewritten, kIndexed, kInfo, kTrace, ""), \ 116 F(traced_buf_chunks_written, kIndexed, kInfo, kTrace, ""), \ 117 F(traced_buf_chunks_committed_out_of_order, \ 118 kIndexed, kInfo, kTrace, ""), \ 119 F(traced_buf_padding_bytes_cleared, kIndexed, kInfo, kTrace, ""), \ 120 F(traced_buf_padding_bytes_written, kIndexed, kInfo, kTrace, ""), \ 121 F(traced_buf_patches_failed, kIndexed, kDataLoss, kTrace, ""), \ 122 F(traced_buf_patches_succeeded, kIndexed, kInfo, kTrace, ""), \ 123 F(traced_buf_readaheads_failed, kIndexed, kInfo, kTrace, ""), \ 124 F(traced_buf_readaheads_succeeded, kIndexed, kInfo, kTrace, ""), \ 125 F(traced_buf_trace_writer_packet_loss, kIndexed, kDataLoss, kTrace, ""), \ 126 F(traced_buf_write_wrap_count, kIndexed, kInfo, kTrace, ""), \ 127 F(traced_chunks_discarded, kSingle, kInfo, kTrace, ""), \ 128 F(traced_data_sources_registered, kSingle, kInfo, kTrace, ""), \ 129 F(traced_data_sources_seen, kSingle, kInfo, kTrace, ""), \ 130 F(traced_final_flush_failed, kSingle, kDataLoss, kTrace, ""), \ 131 F(traced_final_flush_succeeded, kSingle, kInfo, kTrace, ""), \ 132 F(traced_flushes_failed, kSingle, kDataLoss, kTrace, ""), \ 133 F(traced_flushes_requested, kSingle, kInfo, kTrace, ""), \ 134 F(traced_flushes_succeeded, kSingle, kInfo, kTrace, ""), \ 135 F(traced_patches_discarded, kSingle, kInfo, kTrace, ""), \ 136 F(traced_producers_connected, kSingle, kInfo, kTrace, ""), \ 137 F(traced_producers_seen, kSingle, kInfo, kTrace, ""), \ 138 F(traced_total_buffers, kSingle, kInfo, kTrace, ""), \ 139 F(traced_tracing_sessions, kSingle, kInfo, kTrace, ""), \ 140 F(track_event_parser_errors, kSingle, kInfo, kAnalysis, ""), \ 141 F(track_event_dropped_packets_outside_of_range_of_interest, \ 142 kSingle, kInfo, kAnalysis, \ 143 "The number of TrackEvent packets dropped by trace processor due to " \ 144 "being outside of the range of interest. This happens if a trace has a " \ 145 "TrackEventRangeOfInterest packet, and track event dropping is " \ 146 "enabled."), \ 147 F(track_event_tokenizer_errors, kSingle, kInfo, kAnalysis, ""), \ 148 F(track_event_thread_invalid_end, kSingle, kError, kTrace, \ 149 "The end event for a thread track does not match a track event " \ 150 "begin event. This can happen on mixed atrace/track_event traces " \ 151 "and is usually caused by data loss or bugs when the events are " \ 152 "emitted. The outcome of this is that slices can appear to be closed " \ 153 "before they were closed in reality"), \ 154 F(tokenizer_skipped_packets, kSingle, kInfo, kAnalysis, ""), \ 155 F(vmstat_unknown_keys, kSingle, kError, kAnalysis, ""), \ 156 F(vulkan_allocations_invalid_string_id, \ 157 kSingle, kError, kTrace, ""), \ 158 F(clock_sync_failure, kSingle, kError, kAnalysis, ""), \ 159 F(clock_sync_cache_miss, kSingle, kInfo, kAnalysis, ""), \ 160 F(process_tracker_errors, kSingle, kError, kAnalysis, ""), \ 161 F(json_tokenizer_failure, kSingle, kError, kTrace, ""), \ 162 F(json_parser_failure, kSingle, kError, kTrace, ""), \ 163 F(json_display_time_unit, kSingle, kInfo, kTrace, \ 164 "The displayTimeUnit key was set in the JSON trace. In some prior " \ 165 "versions of trace processor this key could effect how the trace " \ 166 "processor parsed timestamps and durations. In this version the key is " \ 167 "ignored which more closely matches the bavahiour of catapult."), \ 168 F(heap_graph_invalid_string_id, kIndexed, kError, kTrace, ""), \ 169 F(heap_graph_non_finalized_graph, kSingle, kError, kTrace, ""), \ 170 F(heap_graph_malformed_packet, kIndexed, kError, kTrace, ""), \ 171 F(heap_graph_missing_packet, kIndexed, kError, kTrace, ""), \ 172 F(heapprofd_buffer_corrupted, kIndexed, kError, kTrace, \ 173 "Shared memory buffer corrupted. This is a bug or memory corruption " \ 174 "in the target. Indexed by target upid."), \ 175 F(heapprofd_hit_guardrail, kIndexed, kError, kTrace, \ 176 "HeapprofdConfig specified a CPU or Memory Guardrail that was hit. " \ 177 "Indexed by target upid."), \ 178 F(heapprofd_buffer_overran, kIndexed, kDataLoss, kTrace, \ 179 "The shared memory buffer between the target and heapprofd overran. " \ 180 "The profile was truncated early. Indexed by target upid."), \ 181 F(heapprofd_client_error, kIndexed, kError, kTrace, \ 182 "The heapprofd client ran into a problem and disconnected. " \ 183 "See profile_packet.proto for error codes."), \ 184 F(heapprofd_client_disconnected, kIndexed, kInfo, kTrace, ""), \ 185 F(heapprofd_malformed_packet, kIndexed, kError, kTrace, ""), \ 186 F(heapprofd_missing_packet, kSingle, kError, kTrace, ""), \ 187 F(heapprofd_rejected_concurrent, kIndexed, kError, kTrace, \ 188 "The target was already profiled by another tracing session, so the " \ 189 "profile was not taken. Indexed by target upid."), \ 190 F(heapprofd_non_finalized_profile, kSingle, kError, kTrace, ""), \ 191 F(heapprofd_sampling_interval_adjusted, \ 192 kIndexed, kInfo, kTrace, \ 193 "By how many byes the interval for PID was increased " \ 194 "by adaptive sampling."), \ 195 F(heapprofd_unwind_time_us, kIndexed, kInfo, kTrace, \ 196 "Time spent unwinding callstacks."), \ 197 F(heapprofd_unwind_samples, kIndexed, kInfo, kTrace, \ 198 "Number of samples unwound."), \ 199 F(heapprofd_client_spinlock_blocked, kIndexed, kInfo, kTrace, \ 200 "Time (us) the heapprofd client was blocked on the spinlock."), \ 201 F(heapprofd_last_profile_timestamp, kIndexed, kInfo, kTrace, \ 202 "The timestamp (in trace time) for the last dump for a process"), \ 203 F(symbolization_tmp_build_id_not_found, kSingle, kError, kAnalysis, \ 204 "Number of file mappings in /data/local/tmp without a build id. " \ 205 "Symbolization doesn't work for executables in /data/local/tmp " \ 206 "because of SELinux. Please use /data/local/tests"), \ 207 F(metatrace_overruns, kSingle, kError, kTrace, ""), \ 208 F(packages_list_has_parse_errors, kSingle, kError, kTrace, ""), \ 209 F(packages_list_has_read_errors, kSingle, kError, kTrace, ""), \ 210 F(game_intervention_has_parse_errors, kSingle, kError, kTrace, \ 211 "One or more parsing errors occurred. This could result from " \ 212 "unknown game more or intervention added to the file to be parsed."), \ 213 F(game_intervention_has_read_errors, kSingle, kError, kTrace, \ 214 "The file to be parsed can't be opened. This can happend when " \ 215 "the file name is not found or no permission to access the file"), \ 216 F(compact_sched_has_parse_errors, kSingle, kError, kTrace, ""), \ 217 F(misplaced_end_event, kSingle, kDataLoss, kAnalysis, ""), \ 218 F(truncated_sys_write_duration, kSingle, kDataLoss, kAnalysis, \ 219 "Count of sys_write slices that have a truncated duration to resolve " \ 220 "nesting incompatibilities with atrace slices. Real durations " \ 221 "can be recovered via the |raw| table."), \ 222 F(sched_waking_out_of_order, kSingle, kError, kAnalysis, ""), \ 223 F(compact_sched_switch_skipped, kSingle, kInfo, kAnalysis, ""), \ 224 F(compact_sched_waking_skipped, kSingle, kInfo, kAnalysis, ""), \ 225 F(empty_chrome_metadata, kSingle, kError, kTrace, ""), \ 226 F(ninja_parse_errors, kSingle, kError, kTrace, ""), \ 227 F(perf_cpu_lost_records, kIndexed, kDataLoss, kTrace, ""), \ 228 F(perf_process_shard_count, kIndexed, kInfo, kTrace, ""), \ 229 F(perf_chosen_process_shard, kIndexed, kInfo, kTrace, ""), \ 230 F(perf_guardrail_stop_ts, kIndexed, kDataLoss, kTrace, ""), \ 231 F(perf_samples_skipped, kSingle, kInfo, kTrace, ""), \ 232 F(perf_samples_skipped_dataloss, kSingle, kDataLoss, kTrace, ""), \ 233 F(memory_snapshot_parser_failure, kSingle, kError, kAnalysis, ""), \ 234 F(thread_time_in_state_out_of_order, kSingle, kError, kAnalysis, ""), \ 235 F(thread_time_in_state_unknown_cpu_freq, \ 236 kSingle, kError, kAnalysis, ""), \ 237 F(ftrace_packet_before_tracing_start, kSingle, kInfo, kAnalysis, \ 238 "An ftrace packet was seen before the tracing start timestamp from " \ 239 "the tracing service. This happens if the ftrace buffers were not " \ 240 "cleared properly. These packets are silently dropped by trace " \ 241 "processor."), \ 242 F(sorter_push_event_out_of_order, kSingle, kError, kTrace, \ 243 "Trace events are out of order event after sorting. This can happen " \ 244 "due to many factors including clock sync drift, producers emitting " \ 245 "events out of order or a bug in trace processor's logic of sorting."), \ 246 F(unknown_extension_fields, kSingle, kError, kTrace, \ 247 "TraceEvent had unknown extension fields, which might result in " \ 248 "missing some arguments. You may need a newer version of trace " \ 249 "processor to parse them."), \ 250 F(network_trace_intern_errors, kSingle, kInfo, kAnalysis, ""), \ 251 F(network_trace_parse_errors, kSingle, kInfo, kAnalysis, "") 252 // clang-format on 253 254 enum Type { 255 kSingle, // Single-value property, one value per key. 256 kIndexed // Indexed property, multiple value per key (e.g. cpu_stats[1]). 257 }; 258 259 enum Severity { 260 kInfo, // Diagnostic counters 261 kDataLoss, // Correct operation that still resulted in data loss 262 kError // If any kError counter is > 0 trace_processor_shell will 263 // raise an error. This is also surfaced in the web UI. 264 }; 265 266 enum Source { 267 // The counter is collected when recording the trace on-device and is just 268 // being reflected in the stats table. 269 kTrace, 270 271 // The counter is genrated when importing / processing the trace in the trace 272 // processor. 273 kAnalysis 274 }; 275 276 // Ignore GCC warning about a missing argument for a variadic macro parameter. 277 #if defined(__GNUC__) || defined(__clang__) 278 #pragma GCC system_header 279 #endif 280 281 // Declares an enum of literals (one for each stat). The enum values of each 282 // literal corresponds to the string index in the arrays below. 283 #define PERFETTO_TP_STATS_ENUM(name, ...) name 284 enum KeyIDs : size_t { PERFETTO_TP_STATS(PERFETTO_TP_STATS_ENUM), kNumKeys }; 285 286 // The code below declares an array for each property (name, type, ...). 287 288 #define PERFETTO_TP_STATS_NAME(name, ...) #name 289 constexpr char const* kNames[] = {PERFETTO_TP_STATS(PERFETTO_TP_STATS_NAME)}; 290 291 #define PERFETTO_TP_STATS_TYPE(_, type, ...) type 292 constexpr Type kTypes[] = {PERFETTO_TP_STATS(PERFETTO_TP_STATS_TYPE)}; 293 294 #define PERFETTO_TP_STATS_SEVERITY(_, __, severity, ...) severity 295 constexpr Severity kSeverities[] = { 296 PERFETTO_TP_STATS(PERFETTO_TP_STATS_SEVERITY)}; 297 298 #define PERFETTO_TP_STATS_SOURCE(_, __, ___, source, ...) source 299 constexpr Source kSources[] = {PERFETTO_TP_STATS(PERFETTO_TP_STATS_SOURCE)}; 300 301 #define PERFETTO_TP_STATS_DESCRIPTION(_, __, ___, ____, descr, ...) descr 302 constexpr char const* kDescriptions[] = { 303 PERFETTO_TP_STATS(PERFETTO_TP_STATS_DESCRIPTION)}; 304 305 } // namespace stats 306 } // namespace trace_processor 307 } // namespace perfetto 308 309 #endif // SRC_TRACE_PROCESSOR_STORAGE_STATS_H_ 310