• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_STATS_H_
18 #define SRC_TRACE_PROCESSOR_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_log_num_failed,                     kSingle,  kError, kTrace),    \
30   F(android_log_num_skipped,                    kSingle,  kError, kTrace),    \
31   F(android_log_num_total,                      kSingle,  kInfo,  kTrace),    \
32   F(atrace_tgid_mismatch,                       kSingle,  kError, kTrace),    \
33   F(clock_snapshot_not_monotonic,               kSingle,  kError, kTrace),    \
34   F(counter_events_out_of_order,                kSingle,  kError, kAnalysis), \
35   F(ftrace_bundle_tokenizer_errors,             kSingle,  kError, kAnalysis), \
36   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, kError, kTrace),    \
49   F(ftrace_cpu_overrun_end,                     kIndexed, kError, kTrace),    \
50   F(ftrace_cpu_read_events_begin,               kIndexed, kInfo,  kTrace),    \
51   F(ftrace_cpu_read_events_end,                 kIndexed, kInfo,  kTrace),    \
52   F(guess_trace_type_duration_ns,               kSingle,  kInfo,  kAnalysis), \
53   F(interned_data_tokenizer_errors,             kSingle,  kInfo,  kAnalysis), \
54   F(invalid_clock_snapshots,                    kSingle,  kError, kAnalysis), \
55   F(invalid_cpu_times,                          kSingle,  kError, kAnalysis), \
56   F(meminfo_unknown_keys,                       kSingle,  kError, kAnalysis), \
57   F(mismatched_sched_switch_tids,               kSingle,  kError, kAnalysis), \
58   F(mm_unknown_type,                            kSingle,  kError, kAnalysis), \
59   F(parse_trace_duration_ns,                    kSingle,  kInfo,  kAnalysis), \
60   F(power_rail_unknown_index,                   kSingle,  kError, kTrace), \
61   F(proc_stat_unknown_counters,                 kSingle,  kError, kAnalysis), \
62   F(rss_stat_unknown_keys,                      kSingle,  kError, kAnalysis), \
63   F(rss_stat_negative_size,                     kSingle,  kInfo,  kAnalysis), \
64   F(sched_switch_out_of_order,                  kSingle,  kError, kAnalysis), \
65   F(systrace_parse_failure,                     kSingle,  kError, kAnalysis), \
66   F(traced_buf_buffer_size,                     kIndexed, kInfo,  kTrace),    \
67   F(traced_buf_bytes_overwritten,               kIndexed, kInfo,  kTrace),    \
68   F(traced_buf_bytes_read,                      kIndexed, kInfo,  kTrace),    \
69   F(traced_buf_bytes_written,                   kIndexed, kInfo,  kTrace),    \
70   F(traced_buf_chunks_discarded,                kIndexed, kInfo,  kTrace),    \
71   F(traced_buf_chunks_overwritten,              kIndexed, kInfo,  kTrace),    \
72   F(traced_buf_chunks_read,                     kIndexed, kInfo,  kTrace),    \
73   F(traced_buf_chunks_rewritten,                kIndexed, kInfo,  kTrace),    \
74   F(traced_buf_chunks_written,                  kIndexed, kInfo,  kTrace),    \
75   F(traced_buf_chunks_committed_out_of_order,   kIndexed, kInfo,  kTrace),    \
76   F(traced_buf_padding_bytes_cleared,           kIndexed, kInfo,  kTrace),    \
77   F(traced_buf_padding_bytes_written,           kIndexed, kInfo,  kTrace),    \
78   F(traced_buf_patches_failed,                  kIndexed, kInfo,  kTrace),    \
79   F(traced_buf_patches_succeeded,               kIndexed, kInfo,  kTrace),    \
80   F(traced_buf_readaheads_failed,               kIndexed, kInfo,  kTrace),    \
81   F(traced_buf_readaheads_succeeded,            kIndexed, kInfo,  kTrace),    \
82   F(traced_buf_write_wrap_count,                kIndexed, kInfo,  kTrace),    \
83   F(traced_chunks_discarded,                    kSingle,  kInfo,  kTrace),    \
84   F(traced_data_sources_registered,             kSingle,  kInfo,  kTrace),    \
85   F(traced_data_sources_seen,                   kSingle,  kInfo,  kTrace),    \
86   F(traced_patches_discarded,                   kSingle,  kInfo,  kTrace),    \
87   F(traced_producers_connected,                 kSingle,  kInfo,  kTrace),    \
88   F(traced_producers_seen,                      kSingle,  kInfo,  kTrace),    \
89   F(traced_total_buffers,                       kSingle,  kInfo,  kTrace),    \
90   F(traced_tracing_sessions,                    kSingle,  kInfo,  kTrace),    \
91   F(track_event_tokenizer_errors,               kSingle,  kInfo,  kAnalysis), \
92   F(track_event_tokenizer_skipped_packets,      kSingle,  kInfo,  kAnalysis), \
93   F(vmstat_unknown_keys,                        kSingle,  kError, kAnalysis), \
94   F(clock_sync_failure,                         kSingle,  kError, kAnalysis), \
95   F(process_tracker_errors,                     kSingle,  kError, kAnalysis), \
96   F(json_tokenizer_failure,                     kSingle,  kError, kTrace),    \
97   F(heapprofd_buffer_corrupted,                 kIndexed, kError, kTrace),    \
98   F(heapprofd_buffer_overran,                   kIndexed, kError, kTrace),    \
99   F(heapprofd_rejected_concurrent,              kIndexed, kError, kTrace),    \
100   F(heapprofd_invalid_string_id,                kSingle,  kError, kTrace),    \
101   F(heapprofd_invalid_mapping_id,               kSingle,  kError, kTrace),    \
102   F(heapprofd_invalid_frame_id,                 kSingle,  kError, kTrace),    \
103   F(heapprofd_invalid_callstack_id,             kSingle,  kError, kTrace)
104 // clang-format on
105 
106 enum Type {
107   kSingle,  // Single-value property, one value per key.
108   kIndexed  // Indexed property, multiple value per key (e.g. cpu_stats[1]).
109 };
110 
111 enum Severity {
112   kInfo,  // Diagnostic counters
113   kError  // If any kError counter is > 0 the UI will raise an error.
114 };
115 
116 enum Source {
117   // The counter is collected when recording the trace on-device and is just
118   // being reflected in the stats table.
119   kTrace,
120 
121   // The counter is genrated when importing / processing the trace in the trace
122   // processor.
123   kAnalysis
124 };
125 
126 // Declares an enum of literals (one for each stat). The enum values of each
127 // literal corresponds to the string index in the arrays below.
128 #define PERFETTO_TP_STATS_ENUM(name, ...) name
129 enum KeyIDs : size_t { PERFETTO_TP_STATS(PERFETTO_TP_STATS_ENUM), kNumKeys };
130 
131 // The code below declares an array for each property (name, type, ...).
132 
133 #define PERFETTO_TP_STATS_NAME(name, ...) #name
134 constexpr char const* kNames[] = {PERFETTO_TP_STATS(PERFETTO_TP_STATS_NAME)};
135 
136 #define PERFETTO_TP_STATS_TYPE(_, type, ...) type
137 constexpr Type kTypes[] = {PERFETTO_TP_STATS(PERFETTO_TP_STATS_TYPE)};
138 
139 #define PERFETTO_TP_STATS_SEVERITY(_, __, severity, ...) severity
140 constexpr Severity kSeverities[] = {
141     PERFETTO_TP_STATS(PERFETTO_TP_STATS_SEVERITY)};
142 
143 #define PERFETTO_TP_STATS_SOURCE(_, __, ___, source, ...) source
144 constexpr Source kSources[] = {PERFETTO_TP_STATS(PERFETTO_TP_STATS_SOURCE)};
145 
146 }  // namespace stats
147 }  // namespace trace_processor
148 }  // namespace perfetto
149 
150 #endif  // SRC_TRACE_PROCESSOR_STATS_H_
151