Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 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 | |
| 17 | #ifndef SRC_TRACE_PROCESSOR_TRACE_STORAGE_H_ |
| 18 | #define SRC_TRACE_PROCESSOR_TRACE_STORAGE_H_ |
| 19 | |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 20 | #include <array> |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 21 | #include <deque> |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 22 | #include <map> |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 23 | #include <string> |
| 24 | #include <unordered_map> |
Ioannis Ilkos | b8b1110 | 2019-01-29 17:56:55 +0000 | [diff] [blame^] | 25 | #include <utility> |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 26 | #include <vector> |
| 27 | |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 28 | #include "perfetto/base/logging.h" |
Lalit Maganti | 770886a | 2018-11-16 17:40:21 +0000 | [diff] [blame] | 29 | #include "perfetto/base/optional.h" |
Primiano Tucci | 2da5d2e | 2018-08-10 14:23:31 +0100 | [diff] [blame] | 30 | #include "perfetto/base/string_view.h" |
Hector Dearman | c833993 | 2018-08-10 11:22:46 +0100 | [diff] [blame] | 31 | #include "perfetto/base/utils.h" |
Lalit Maganti | b0b53ee | 2019-01-24 17:53:39 +0000 | [diff] [blame] | 32 | #include "src/trace_processor/ftrace_utils.h" |
Primiano Tucci | 0e38a14 | 2019-01-07 20:51:09 +0000 | [diff] [blame] | 33 | #include "src/trace_processor/stats.h" |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 34 | |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 35 | namespace perfetto { |
| 36 | namespace trace_processor { |
| 37 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 38 | // UniquePid is an offset into |unique_processes_|. This is necessary because |
| 39 | // Unix pids are reused and thus not guaranteed to be unique over a long |
| 40 | // period of time. |
| 41 | using UniquePid = uint32_t; |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 42 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 43 | // UniqueTid is an offset into |unique_threads_|. Necessary because tids can |
| 44 | // be reused. |
| 45 | using UniqueTid = uint32_t; |
| 46 | |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 47 | // StringId is an offset into |string_pool_|. |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 48 | using StringId = uint32_t; |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 49 | |
Lalit Maganti | 5ea9e93 | 2018-11-30 14:19:39 +0000 | [diff] [blame] | 50 | // Identifiers for all the tables in the database. |
| 51 | enum TableId : uint8_t { |
| 52 | // Intentionally don't have TableId == 0 so that RowId == 0 can refer to an |
| 53 | // invalid row id. |
| 54 | kCounters = 1, |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 55 | kRawEvents = 2, |
Lalit Maganti | 66ed7ad | 2019-01-11 16:47:26 +0000 | [diff] [blame] | 56 | kInstants = 3, |
Lalit Maganti | 5ea9e93 | 2018-11-30 14:19:39 +0000 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | // The top 8 bits are set to the TableId and the bottom 32 to the row of the |
| 60 | // table. |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 61 | using RowId = int64_t; |
Lalit Maganti | 5ea9e93 | 2018-11-30 14:19:39 +0000 | [diff] [blame] | 62 | |
| 63 | static const RowId kInvalidRowId = 0; |
| 64 | |
Isabelle Taylor | a97c5f5 | 2018-10-23 17:36:12 +0100 | [diff] [blame] | 65 | enum RefType { |
Primiano Tucci | 5403e4f | 2018-11-27 10:07:03 +0000 | [diff] [blame] | 66 | kRefNoRef = 0, |
| 67 | kRefUtid = 1, |
| 68 | kRefCpuId = 2, |
| 69 | kRefIrq = 3, |
| 70 | kRefSoftIrq = 4, |
| 71 | kRefUpid = 5, |
| 72 | kRefUtidLookupUpid = 6, |
| 73 | kRefMax |
Isabelle Taylor | a97c5f5 | 2018-10-23 17:36:12 +0100 | [diff] [blame] | 74 | }; |
Isabelle Taylor | 14674d4 | 2018-09-07 11:33:11 +0100 | [diff] [blame] | 75 | |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 76 | // Stores a data inside a trace file in a columnar form. This makes it efficient |
| 77 | // to read or search across a single field of the trace (e.g. all the thread |
| 78 | // names for a given CPU). |
| 79 | class TraceStorage { |
| 80 | public: |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 81 | TraceStorage(); |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 82 | TraceStorage(const TraceStorage&) = delete; |
| 83 | |
| 84 | virtual ~TraceStorage(); |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 85 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 86 | // Information about a unique process seen in a trace. |
| 87 | struct Process { |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 88 | explicit Process(uint32_t p) : pid(p) {} |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 89 | int64_t start_ns = 0; |
| 90 | int64_t end_ns = 0; |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 91 | StringId name_id = 0; |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 92 | uint32_t pid = 0; |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | // Information about a unique thread seen in a trace. |
| 96 | struct Thread { |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 97 | explicit Thread(uint32_t t) : tid(t) {} |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 98 | int64_t start_ns = 0; |
| 99 | int64_t end_ns = 0; |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 100 | StringId name_id = 0; |
Lalit Maganti | 770886a | 2018-11-16 17:40:21 +0000 | [diff] [blame] | 101 | base::Optional<UniquePid> upid; |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 102 | uint32_t tid = 0; |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 103 | }; |
Isabelle Taylor | 3dd366c | 2018-06-22 16:21:41 +0100 | [diff] [blame] | 104 | |
Lalit Maganti | 6e9c55e | 2018-11-29 12:00:39 +0000 | [diff] [blame] | 105 | // Generic key value storage which can be referenced by other tables. |
| 106 | class Args { |
| 107 | public: |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 108 | // Variadic type representing the possible values for the args table. |
| 109 | struct Variadic { |
Lalit Maganti | 6e9c55e | 2018-11-29 12:00:39 +0000 | [diff] [blame] | 110 | enum Type { kInt, kString, kReal }; |
| 111 | |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 112 | static Variadic Integer(int64_t int_value) { |
| 113 | Variadic variadic; |
| 114 | variadic.type = Type::kInt; |
| 115 | variadic.int_value = int_value; |
| 116 | return variadic; |
| 117 | } |
| 118 | |
| 119 | static Variadic String(StringId string_id) { |
| 120 | Variadic variadic; |
| 121 | variadic.type = Type::kString; |
| 122 | variadic.string_value = string_id; |
| 123 | return variadic; |
| 124 | } |
| 125 | |
| 126 | static Variadic Real(double real_value) { |
| 127 | Variadic variadic; |
| 128 | variadic.type = Type::kReal; |
| 129 | variadic.real_value = real_value; |
| 130 | return variadic; |
| 131 | } |
Lalit Maganti | 6e9c55e | 2018-11-29 12:00:39 +0000 | [diff] [blame] | 132 | |
| 133 | Type type; |
| 134 | union { |
| 135 | int64_t int_value; |
| 136 | StringId string_value; |
| 137 | double real_value; |
| 138 | }; |
| 139 | }; |
| 140 | |
Lalit Maganti | 5ea9e93 | 2018-11-30 14:19:39 +0000 | [diff] [blame] | 141 | const std::deque<RowId>& ids() const { return ids_; } |
| 142 | const std::deque<StringId>& flat_keys() const { return flat_keys_; } |
| 143 | const std::deque<StringId>& keys() const { return keys_; } |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 144 | const std::deque<Variadic>& arg_values() const { return arg_values_; } |
Lalit Maganti | 79472be | 2018-12-04 13:41:27 +0000 | [diff] [blame] | 145 | const std::multimap<RowId, uint32_t>& args_for_id() const { |
| 146 | return args_for_id_; |
| 147 | } |
Lalit Maganti | 6e9c55e | 2018-11-29 12:00:39 +0000 | [diff] [blame] | 148 | size_t args_count() const { return ids_.size(); } |
| 149 | |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 150 | void AddArg(RowId id, StringId flat_key, StringId key, Variadic value) { |
Lalit Maganti | cc67422 | 2019-01-23 17:54:00 +0000 | [diff] [blame] | 151 | // TODO(b/123252504): disable this code to stop blow-ups in ingestion time |
| 152 | // and memory. |
| 153 | perfetto::base::ignore_result(id); |
| 154 | perfetto::base::ignore_result(flat_key); |
| 155 | perfetto::base::ignore_result(key); |
| 156 | perfetto::base::ignore_result(value); |
| 157 | /* |
Lalit Maganti | 5ea9e93 | 2018-11-30 14:19:39 +0000 | [diff] [blame] | 158 | if (id == kInvalidRowId) |
| 159 | return; |
| 160 | |
| 161 | ids_.emplace_back(id); |
| 162 | flat_keys_.emplace_back(flat_key); |
| 163 | keys_.emplace_back(key); |
| 164 | arg_values_.emplace_back(value); |
Lalit Maganti | 79472be | 2018-12-04 13:41:27 +0000 | [diff] [blame] | 165 | args_for_id_.emplace(id, static_cast<uint32_t>(args_count() - 1)); |
Lalit Maganti | cc67422 | 2019-01-23 17:54:00 +0000 | [diff] [blame] | 166 | */ |
Lalit Maganti | 6e9c55e | 2018-11-29 12:00:39 +0000 | [diff] [blame] | 167 | } |
| 168 | |
Lalit Maganti | 5ea9e93 | 2018-11-30 14:19:39 +0000 | [diff] [blame] | 169 | private: |
| 170 | std::deque<RowId> ids_; |
| 171 | std::deque<StringId> flat_keys_; |
| 172 | std::deque<StringId> keys_; |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 173 | std::deque<Variadic> arg_values_; |
Lalit Maganti | 79472be | 2018-12-04 13:41:27 +0000 | [diff] [blame] | 174 | std::multimap<RowId, uint32_t> args_for_id_; |
Lalit Maganti | 6e9c55e | 2018-11-29 12:00:39 +0000 | [diff] [blame] | 175 | }; |
| 176 | |
Lalit Maganti | ff69c11 | 2018-09-24 12:07:47 +0100 | [diff] [blame] | 177 | class Slices { |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 178 | public: |
Lalit Maganti | fde2904 | 2018-10-04 13:28:52 +0100 | [diff] [blame] | 179 | inline size_t AddSlice(uint32_t cpu, |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 180 | int64_t start_ns, |
| 181 | int64_t duration_ns, |
Lalit Maganti | b0b53ee | 2019-01-24 17:53:39 +0000 | [diff] [blame] | 182 | UniqueTid utid, |
| 183 | ftrace_utils::TaskState end_state, |
| 184 | int32_t priority) { |
Lalit Maganti | ff69c11 | 2018-09-24 12:07:47 +0100 | [diff] [blame] | 185 | cpus_.emplace_back(cpu); |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 186 | start_ns_.emplace_back(start_ns); |
| 187 | durations_.emplace_back(duration_ns); |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 188 | utids_.emplace_back(utid); |
Lalit Maganti | b0b53ee | 2019-01-24 17:53:39 +0000 | [diff] [blame] | 189 | end_states_.emplace_back(end_state); |
| 190 | priorities_.emplace_back(priority); |
Lalit Maganti | f0f09c3 | 2019-01-18 17:29:31 +0000 | [diff] [blame] | 191 | rows_for_utids_.emplace(utid, slice_count() - 1); |
Lalit Maganti | fde2904 | 2018-10-04 13:28:52 +0100 | [diff] [blame] | 192 | return slice_count() - 1; |
| 193 | } |
| 194 | |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 195 | void set_duration(size_t index, int64_t duration_ns) { |
Lalit Maganti | fde2904 | 2018-10-04 13:28:52 +0100 | [diff] [blame] | 196 | durations_[index] = duration_ns; |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 197 | } |
| 198 | |
Lalit Maganti | b0b53ee | 2019-01-24 17:53:39 +0000 | [diff] [blame] | 199 | void set_end_state(size_t index, ftrace_utils::TaskState end_state) { |
| 200 | end_states_[index] = end_state; |
| 201 | } |
| 202 | |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 203 | size_t slice_count() const { return start_ns_.size(); } |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 204 | |
Lalit Maganti | ff69c11 | 2018-09-24 12:07:47 +0100 | [diff] [blame] | 205 | const std::deque<uint32_t>& cpus() const { return cpus_; } |
| 206 | |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 207 | const std::deque<int64_t>& start_ns() const { return start_ns_; } |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 208 | |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 209 | const std::deque<int64_t>& durations() const { return durations_; } |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 210 | |
Isabelle Taylor | 68e4219 | 2018-06-19 16:19:31 +0100 | [diff] [blame] | 211 | const std::deque<UniqueTid>& utids() const { return utids_; } |
| 212 | |
Lalit Maganti | b0b53ee | 2019-01-24 17:53:39 +0000 | [diff] [blame] | 213 | const std::deque<ftrace_utils::TaskState>& end_state() const { |
| 214 | return end_states_; |
| 215 | } |
| 216 | |
| 217 | const std::deque<int32_t>& priorities() const { return priorities_; } |
| 218 | |
Lalit Maganti | f0f09c3 | 2019-01-18 17:29:31 +0000 | [diff] [blame] | 219 | const std::multimap<UniqueTid, uint32_t>& rows_for_utids() const { |
| 220 | return rows_for_utids_; |
| 221 | } |
| 222 | |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 223 | private: |
Hector Dearman | 947f12a | 2018-09-11 16:50:36 +0100 | [diff] [blame] | 224 | // Each deque below has the same number of entries (the number of slices |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 225 | // in the trace for the CPU). |
Lalit Maganti | ff69c11 | 2018-09-24 12:07:47 +0100 | [diff] [blame] | 226 | std::deque<uint32_t> cpus_; |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 227 | std::deque<int64_t> start_ns_; |
| 228 | std::deque<int64_t> durations_; |
Isabelle Taylor | 68e4219 | 2018-06-19 16:19:31 +0100 | [diff] [blame] | 229 | std::deque<UniqueTid> utids_; |
Lalit Maganti | b0b53ee | 2019-01-24 17:53:39 +0000 | [diff] [blame] | 230 | std::deque<ftrace_utils::TaskState> end_states_; |
| 231 | std::deque<int32_t> priorities_; |
Lalit Maganti | f0f09c3 | 2019-01-18 17:29:31 +0000 | [diff] [blame] | 232 | std::multimap<UniqueTid, uint32_t> rows_for_utids_; |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 233 | }; |
Isabelle Taylor | 68e4219 | 2018-06-19 16:19:31 +0100 | [diff] [blame] | 234 | |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 235 | class NestableSlices { |
| 236 | public: |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 237 | inline size_t AddSlice(int64_t start_ns, |
| 238 | int64_t duration_ns, |
Lalit Maganti | 7b37bbf | 2018-11-09 15:58:54 +0000 | [diff] [blame] | 239 | UniqueTid utid, |
| 240 | StringId cat, |
| 241 | StringId name, |
| 242 | uint8_t depth, |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 243 | int64_t stack_id, |
| 244 | int64_t parent_stack_id) { |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 245 | start_ns_.emplace_back(start_ns); |
| 246 | durations_.emplace_back(duration_ns); |
| 247 | utids_.emplace_back(utid); |
| 248 | cats_.emplace_back(cat); |
| 249 | names_.emplace_back(name); |
| 250 | depths_.emplace_back(depth); |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 251 | stack_ids_.emplace_back(stack_id); |
| 252 | parent_stack_ids_.emplace_back(parent_stack_id); |
Lalit Maganti | 7b37bbf | 2018-11-09 15:58:54 +0000 | [diff] [blame] | 253 | return slice_count() - 1; |
| 254 | } |
| 255 | |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 256 | void set_duration(size_t index, int64_t duration_ns) { |
Lalit Maganti | 7b37bbf | 2018-11-09 15:58:54 +0000 | [diff] [blame] | 257 | durations_[index] = duration_ns; |
| 258 | } |
| 259 | |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 260 | void set_stack_id(size_t index, int64_t stack_id) { |
Lalit Maganti | 7b37bbf | 2018-11-09 15:58:54 +0000 | [diff] [blame] | 261 | stack_ids_[index] = stack_id; |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | size_t slice_count() const { return start_ns_.size(); } |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 265 | const std::deque<int64_t>& start_ns() const { return start_ns_; } |
| 266 | const std::deque<int64_t>& durations() const { return durations_; } |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 267 | const std::deque<UniqueTid>& utids() const { return utids_; } |
| 268 | const std::deque<StringId>& cats() const { return cats_; } |
| 269 | const std::deque<StringId>& names() const { return names_; } |
| 270 | const std::deque<uint8_t>& depths() const { return depths_; } |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 271 | const std::deque<int64_t>& stack_ids() const { return stack_ids_; } |
| 272 | const std::deque<int64_t>& parent_stack_ids() const { |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 273 | return parent_stack_ids_; |
| 274 | } |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 275 | |
| 276 | private: |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 277 | std::deque<int64_t> start_ns_; |
| 278 | std::deque<int64_t> durations_; |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 279 | std::deque<UniqueTid> utids_; |
| 280 | std::deque<StringId> cats_; |
| 281 | std::deque<StringId> names_; |
| 282 | std::deque<uint8_t> depths_; |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 283 | std::deque<int64_t> stack_ids_; |
| 284 | std::deque<int64_t> parent_stack_ids_; |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 285 | }; |
| 286 | |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 287 | class Counters { |
| 288 | public: |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 289 | inline size_t AddCounter(int64_t timestamp, |
| 290 | int64_t duration, |
Lalit Maganti | fde2904 | 2018-10-04 13:28:52 +0100 | [diff] [blame] | 291 | StringId name_id, |
| 292 | double value, |
Lalit Maganti | fde2904 | 2018-10-04 13:28:52 +0100 | [diff] [blame] | 293 | int64_t ref, |
| 294 | RefType type) { |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 295 | timestamps_.emplace_back(timestamp); |
| 296 | durations_.emplace_back(duration); |
| 297 | name_ids_.emplace_back(name_id); |
| 298 | values_.emplace_back(value); |
| 299 | refs_.emplace_back(ref); |
| 300 | types_.emplace_back(type); |
Lalit Maganti | fde2904 | 2018-10-04 13:28:52 +0100 | [diff] [blame] | 301 | return counter_count() - 1; |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 302 | } |
Lalit Maganti | fde2904 | 2018-10-04 13:28:52 +0100 | [diff] [blame] | 303 | |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 304 | void set_duration(size_t index, int64_t duration) { |
Lalit Maganti | fde2904 | 2018-10-04 13:28:52 +0100 | [diff] [blame] | 305 | durations_[index] = duration; |
| 306 | } |
| 307 | |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 308 | size_t counter_count() const { return timestamps_.size(); } |
| 309 | |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 310 | const std::deque<int64_t>& timestamps() const { return timestamps_; } |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 311 | |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 312 | const std::deque<int64_t>& durations() const { return durations_; } |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 313 | |
| 314 | const std::deque<StringId>& name_ids() const { return name_ids_; } |
| 315 | |
| 316 | const std::deque<double>& values() const { return values_; } |
| 317 | |
| 318 | const std::deque<int64_t>& refs() const { return refs_; } |
| 319 | |
| 320 | const std::deque<RefType>& types() const { return types_; } |
| 321 | |
| 322 | private: |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 323 | std::deque<int64_t> timestamps_; |
| 324 | std::deque<int64_t> durations_; |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 325 | std::deque<StringId> name_ids_; |
| 326 | std::deque<double> values_; |
| 327 | std::deque<int64_t> refs_; |
| 328 | std::deque<RefType> types_; |
| 329 | }; |
| 330 | |
Primiano Tucci | 5cb84f8 | 2018-10-31 21:46:36 -0700 | [diff] [blame] | 331 | class SqlStats { |
| 332 | public: |
| 333 | static constexpr size_t kMaxLogEntries = 100; |
| 334 | void RecordQueryBegin(const std::string& query, |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 335 | int64_t time_queued, |
| 336 | int64_t time_started); |
| 337 | void RecordQueryEnd(int64_t time_ended); |
Primiano Tucci | 5cb84f8 | 2018-10-31 21:46:36 -0700 | [diff] [blame] | 338 | size_t size() const { return queries_.size(); } |
| 339 | const std::deque<std::string>& queries() const { return queries_; } |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 340 | const std::deque<int64_t>& times_queued() const { return times_queued_; } |
| 341 | const std::deque<int64_t>& times_started() const { return times_started_; } |
| 342 | const std::deque<int64_t>& times_ended() const { return times_ended_; } |
Primiano Tucci | 5cb84f8 | 2018-10-31 21:46:36 -0700 | [diff] [blame] | 343 | |
| 344 | private: |
| 345 | std::deque<std::string> queries_; |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 346 | std::deque<int64_t> times_queued_; |
| 347 | std::deque<int64_t> times_started_; |
| 348 | std::deque<int64_t> times_ended_; |
Primiano Tucci | 5cb84f8 | 2018-10-31 21:46:36 -0700 | [diff] [blame] | 349 | }; |
| 350 | |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 351 | class Instants { |
| 352 | public: |
Lalit Maganti | 66ed7ad | 2019-01-11 16:47:26 +0000 | [diff] [blame] | 353 | inline uint32_t AddInstantEvent(int64_t timestamp, |
| 354 | StringId name_id, |
| 355 | double value, |
| 356 | int64_t ref, |
| 357 | RefType type) { |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 358 | timestamps_.emplace_back(timestamp); |
| 359 | name_ids_.emplace_back(name_id); |
| 360 | values_.emplace_back(value); |
| 361 | refs_.emplace_back(ref); |
| 362 | types_.emplace_back(type); |
Lalit Maganti | 66ed7ad | 2019-01-11 16:47:26 +0000 | [diff] [blame] | 363 | return static_cast<uint32_t>(instant_count() - 1); |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 364 | } |
| 365 | |
| 366 | size_t instant_count() const { return timestamps_.size(); } |
| 367 | |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 368 | const std::deque<int64_t>& timestamps() const { return timestamps_; } |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 369 | |
| 370 | const std::deque<StringId>& name_ids() const { return name_ids_; } |
| 371 | |
| 372 | const std::deque<double>& values() const { return values_; } |
| 373 | |
| 374 | const std::deque<int64_t>& refs() const { return refs_; } |
| 375 | |
| 376 | const std::deque<RefType>& types() const { return types_; } |
| 377 | |
| 378 | private: |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 379 | std::deque<int64_t> timestamps_; |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 380 | std::deque<StringId> name_ids_; |
| 381 | std::deque<double> values_; |
| 382 | std::deque<int64_t> refs_; |
| 383 | std::deque<RefType> types_; |
| 384 | }; |
| 385 | |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 386 | class RawEvents { |
| 387 | public: |
| 388 | inline RowId AddRawEvent(int64_t timestamp, |
| 389 | StringId name_id, |
Lalit Maganti | e87cc81 | 2019-01-10 15:20:06 +0000 | [diff] [blame] | 390 | uint32_t cpu, |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 391 | UniqueTid utid) { |
| 392 | timestamps_.emplace_back(timestamp); |
| 393 | name_ids_.emplace_back(name_id); |
Lalit Maganti | e87cc81 | 2019-01-10 15:20:06 +0000 | [diff] [blame] | 394 | cpus_.emplace_back(cpu); |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 395 | utids_.emplace_back(utid); |
| 396 | return CreateRowId(TableId::kRawEvents, |
| 397 | static_cast<uint32_t>(raw_event_count() - 1)); |
| 398 | } |
| 399 | |
| 400 | size_t raw_event_count() const { return timestamps_.size(); } |
| 401 | |
| 402 | const std::deque<int64_t>& timestamps() const { return timestamps_; } |
| 403 | |
| 404 | const std::deque<StringId>& name_ids() const { return name_ids_; } |
| 405 | |
Lalit Maganti | e87cc81 | 2019-01-10 15:20:06 +0000 | [diff] [blame] | 406 | const std::deque<uint32_t>& cpus() const { return cpus_; } |
| 407 | |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 408 | const std::deque<UniqueTid>& utids() const { return utids_; } |
| 409 | |
| 410 | private: |
| 411 | std::deque<int64_t> timestamps_; |
| 412 | std::deque<StringId> name_ids_; |
Lalit Maganti | e87cc81 | 2019-01-10 15:20:06 +0000 | [diff] [blame] | 413 | std::deque<uint32_t> cpus_; |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 414 | std::deque<UniqueTid> utids_; |
| 415 | }; |
| 416 | |
Primiano Tucci | 2c761ef | 2019-01-07 20:20:46 +0000 | [diff] [blame] | 417 | class AndroidLogs { |
| 418 | public: |
| 419 | inline size_t AddLogEvent(int64_t timestamp, |
| 420 | UniqueTid utid, |
| 421 | uint8_t prio, |
| 422 | StringId tag_id, |
| 423 | StringId msg_id) { |
| 424 | timestamps_.emplace_back(timestamp); |
| 425 | utids_.emplace_back(utid); |
| 426 | prios_.emplace_back(prio); |
| 427 | tag_ids_.emplace_back(tag_id); |
| 428 | msg_ids_.emplace_back(msg_id); |
| 429 | return size() - 1; |
| 430 | } |
| 431 | |
| 432 | size_t size() const { return timestamps_.size(); } |
| 433 | |
| 434 | const std::deque<int64_t>& timestamps() const { return timestamps_; } |
| 435 | const std::deque<UniqueTid>& utids() const { return utids_; } |
| 436 | const std::deque<uint8_t>& prios() const { return prios_; } |
| 437 | const std::deque<StringId>& tag_ids() const { return tag_ids_; } |
| 438 | const std::deque<StringId>& msg_ids() const { return msg_ids_; } |
| 439 | |
| 440 | private: |
| 441 | std::deque<int64_t> timestamps_; |
| 442 | std::deque<UniqueTid> utids_; |
| 443 | std::deque<uint8_t> prios_; |
| 444 | std::deque<StringId> tag_ids_; |
| 445 | std::deque<StringId> msg_ids_; |
| 446 | }; |
| 447 | |
Primiano Tucci | 0e38a14 | 2019-01-07 20:51:09 +0000 | [diff] [blame] | 448 | struct Stats { |
| 449 | using IndexMap = std::map<int, int64_t>; |
| 450 | int64_t value = 0; |
| 451 | IndexMap indexed_values; |
| 452 | }; |
| 453 | using StatsMap = std::array<Stats, stats::kNumKeys>; |
| 454 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 455 | void ResetStorage(); |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 456 | |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 457 | UniqueTid AddEmptyThread(uint32_t tid) { |
| 458 | unique_threads_.emplace_back(tid); |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 459 | return static_cast<UniqueTid>(unique_threads_.size() - 1); |
| 460 | } |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 461 | |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 462 | UniquePid AddEmptyProcess(uint32_t pid) { |
| 463 | unique_processes_.emplace_back(pid); |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 464 | return static_cast<UniquePid>(unique_processes_.size() - 1); |
| 465 | } |
Isabelle Taylor | 3dd366c | 2018-06-22 16:21:41 +0100 | [diff] [blame] | 466 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 467 | // Return an unqiue identifier for the contents of each string. |
| 468 | // The string is copied internally and can be destroyed after this called. |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 469 | // Virtual for testing. |
| 470 | virtual StringId InternString(base::StringView); |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 471 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 472 | Process* GetMutableProcess(UniquePid upid) { |
Lalit Maganti | 676658b | 2018-11-20 18:24:31 +0000 | [diff] [blame] | 473 | PERFETTO_DCHECK(upid < unique_processes_.size()); |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 474 | return &unique_processes_[upid]; |
| 475 | } |
Isabelle Taylor | 3dd366c | 2018-06-22 16:21:41 +0100 | [diff] [blame] | 476 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 477 | Thread* GetMutableThread(UniqueTid utid) { |
Florian Mayer | a1aaec2 | 2018-09-19 17:02:26 +0100 | [diff] [blame] | 478 | PERFETTO_DCHECK(utid < unique_threads_.size()); |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 479 | return &unique_threads_[utid]; |
| 480 | } |
Isabelle Taylor | 3dd366c | 2018-06-22 16:21:41 +0100 | [diff] [blame] | 481 | |
Primiano Tucci | 0e38a14 | 2019-01-07 20:51:09 +0000 | [diff] [blame] | 482 | // Example usage: SetStats(stats::android_log_num_failed, 42); |
| 483 | void SetStats(size_t key, int64_t value) { |
| 484 | PERFETTO_DCHECK(key < stats::kNumKeys); |
| 485 | PERFETTO_DCHECK(stats::kTypes[key] == stats::kSingle); |
| 486 | stats_[key].value = value; |
| 487 | } |
| 488 | |
| 489 | // Example usage: IncrementStats(stats::android_log_num_failed, -1); |
| 490 | void IncrementStats(size_t key, int64_t increment = 1) { |
| 491 | PERFETTO_DCHECK(key < stats::kNumKeys); |
| 492 | PERFETTO_DCHECK(stats::kTypes[key] == stats::kSingle); |
| 493 | stats_[key].value += increment; |
| 494 | } |
| 495 | |
| 496 | // Example usage: SetIndexedStats(stats::cpu_failure, 1, 42); |
| 497 | void SetIndexedStats(size_t key, int index, int64_t value) { |
| 498 | PERFETTO_DCHECK(key < stats::kNumKeys); |
| 499 | PERFETTO_DCHECK(stats::kTypes[key] == stats::kIndexed); |
| 500 | stats_[key].indexed_values[index] = value; |
| 501 | } |
| 502 | |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 503 | // Reading methods. |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 504 | const std::string& GetString(StringId id) const { |
| 505 | PERFETTO_DCHECK(id < string_pool_.size()); |
| 506 | return string_pool_[id]; |
| 507 | } |
| 508 | |
Lalit Maganti | e9d4053 | 2018-06-29 13:15:06 +0100 | [diff] [blame] | 509 | const Process& GetProcess(UniquePid upid) const { |
Lalit Maganti | 676658b | 2018-11-20 18:24:31 +0000 | [diff] [blame] | 510 | PERFETTO_DCHECK(upid < unique_processes_.size()); |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 511 | return unique_processes_[upid]; |
| 512 | } |
| 513 | |
Lalit Maganti | e9d4053 | 2018-06-29 13:15:06 +0100 | [diff] [blame] | 514 | const Thread& GetThread(UniqueTid utid) const { |
Lalit Maganti | 1f64cfa | 2018-09-18 13:20:02 +0100 | [diff] [blame] | 515 | // Allow utid == 0 for idle thread retrieval. |
Florian Mayer | a1aaec2 | 2018-09-19 17:02:26 +0100 | [diff] [blame] | 516 | PERFETTO_DCHECK(utid < unique_threads_.size()); |
Isabelle Taylor | 68e4219 | 2018-06-19 16:19:31 +0100 | [diff] [blame] | 517 | return unique_threads_[utid]; |
| 518 | } |
| 519 | |
Lalit Maganti | 5ea9e93 | 2018-11-30 14:19:39 +0000 | [diff] [blame] | 520 | static RowId CreateRowId(TableId table, uint32_t row) { |
| 521 | static constexpr uint8_t kRowIdTableShift = 32; |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 522 | return (static_cast<RowId>(table) << kRowIdTableShift) | row; |
Lalit Maganti | 5ea9e93 | 2018-11-30 14:19:39 +0000 | [diff] [blame] | 523 | } |
| 524 | |
Lalit Maganti | ff69c11 | 2018-09-24 12:07:47 +0100 | [diff] [blame] | 525 | const Slices& slices() const { return slices_; } |
Lalit Maganti | fde2904 | 2018-10-04 13:28:52 +0100 | [diff] [blame] | 526 | Slices* mutable_slices() { return &slices_; } |
| 527 | |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 528 | const NestableSlices& nestable_slices() const { return nestable_slices_; } |
| 529 | NestableSlices* mutable_nestable_slices() { return &nestable_slices_; } |
| 530 | |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 531 | const Counters& counters() const { return counters_; } |
| 532 | Counters* mutable_counters() { return &counters_; } |
Isabelle Taylor | 14674d4 | 2018-09-07 11:33:11 +0100 | [diff] [blame] | 533 | |
Primiano Tucci | 5cb84f8 | 2018-10-31 21:46:36 -0700 | [diff] [blame] | 534 | const SqlStats& sql_stats() const { return sql_stats_; } |
| 535 | SqlStats* mutable_sql_stats() { return &sql_stats_; } |
| 536 | |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 537 | const Instants& instants() const { return instants_; } |
| 538 | Instants* mutable_instants() { return &instants_; } |
| 539 | |
Primiano Tucci | 2c761ef | 2019-01-07 20:20:46 +0000 | [diff] [blame] | 540 | const AndroidLogs& android_logs() const { return android_log_; } |
| 541 | AndroidLogs* mutable_android_log() { return &android_log_; } |
| 542 | |
Primiano Tucci | 0e38a14 | 2019-01-07 20:51:09 +0000 | [diff] [blame] | 543 | const StatsMap& stats() const { return stats_; } |
Lalit Maganti | 05e8c13 | 2018-11-09 18:16:12 +0000 | [diff] [blame] | 544 | |
Lalit Maganti | 6e9c55e | 2018-11-29 12:00:39 +0000 | [diff] [blame] | 545 | const Args& args() const { return args_; } |
| 546 | Args* mutable_args() { return &args_; } |
| 547 | |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 548 | const RawEvents& raw_events() const { return raw_events_; } |
| 549 | RawEvents* mutable_raw_events() { return &raw_events_; } |
| 550 | |
Lalit Maganti | acda68b | 2018-10-29 15:23:25 +0000 | [diff] [blame] | 551 | const std::deque<std::string>& string_pool() const { return string_pool_; } |
| 552 | |
Isabelle Taylor | e7003fb | 2018-07-17 11:39:01 +0100 | [diff] [blame] | 553 | // |unique_processes_| always contains at least 1 element becuase the 0th ID |
| 554 | // is reserved to indicate an invalid process. |
Lalit Maganti | 9c6395b | 2019-01-17 00:25:09 +0000 | [diff] [blame] | 555 | size_t process_count() const { return unique_processes_.size(); } |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 556 | |
Isabelle Taylor | e7003fb | 2018-07-17 11:39:01 +0100 | [diff] [blame] | 557 | // |unique_threads_| always contains at least 1 element becuase the 0th ID |
| 558 | // is reserved to indicate an invalid thread. |
Lalit Maganti | 9c6395b | 2019-01-17 00:25:09 +0000 | [diff] [blame] | 559 | size_t thread_count() const { return unique_threads_.size(); } |
Isabelle Taylor | e7003fb | 2018-07-17 11:39:01 +0100 | [diff] [blame] | 560 | |
Hector Dearman | 1232336 | 2018-08-09 16:09:28 +0100 | [diff] [blame] | 561 | // Number of interned strings in the pool. Includes the empty string w/ ID=0. |
| 562 | size_t string_count() const { return string_pool_.size(); } |
| 563 | |
Ioannis Ilkos | b8b1110 | 2019-01-29 17:56:55 +0000 | [diff] [blame^] | 564 | // Start / end ts (in nanoseconds) across the parsed trace events. |
| 565 | // Returns (0, 0) if the trace is empty. |
| 566 | std::pair<int64_t, int64_t> GetTraceTimestampBoundsNs() const; |
| 567 | |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 568 | private: |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 569 | TraceStorage& operator=(const TraceStorage&) = default; |
| 570 | |
Primiano Tucci | 2da5d2e | 2018-08-10 14:23:31 +0100 | [diff] [blame] | 571 | using StringHash = uint64_t; |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 572 | |
Lalit Maganti | 05e8c13 | 2018-11-09 18:16:12 +0000 | [diff] [blame] | 573 | // Stats about parsing the trace. |
Primiano Tucci | 0e38a14 | 2019-01-07 20:51:09 +0000 | [diff] [blame] | 574 | StatsMap stats_{}; |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 575 | |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 576 | // One entry for each CPU in the trace. |
Lalit Maganti | ff69c11 | 2018-09-24 12:07:47 +0100 | [diff] [blame] | 577 | Slices slices_; |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 578 | |
Lalit Maganti | 6e9c55e | 2018-11-29 12:00:39 +0000 | [diff] [blame] | 579 | // Args for all other tables. |
| 580 | Args args_; |
| 581 | |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 582 | // One entry for each unique string in the trace. |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 583 | std::deque<std::string> string_pool_; |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 584 | |
| 585 | // One entry for each unique string in the trace. |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 586 | std::unordered_map<StringHash, StringId> string_index_; |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 587 | |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 588 | // One entry for each UniquePid, with UniquePid as the index. |
Isabelle Taylor | 3dd366c | 2018-06-22 16:21:41 +0100 | [diff] [blame] | 589 | std::deque<Process> unique_processes_; |
Isabelle Taylor | 68e4219 | 2018-06-19 16:19:31 +0100 | [diff] [blame] | 590 | |
Isabelle Taylor | 68e4219 | 2018-06-19 16:19:31 +0100 | [diff] [blame] | 591 | // One entry for each UniqueTid, with UniqueTid as the index. |
Isabelle Taylor | 3dd366c | 2018-06-22 16:21:41 +0100 | [diff] [blame] | 592 | std::deque<Thread> unique_threads_; |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 593 | |
| 594 | // Slices coming from userspace events (e.g. Chromium TRACE_EVENT macros). |
| 595 | NestableSlices nestable_slices_; |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 596 | |
| 597 | // Counter events from the trace. This includes CPU frequency events as well |
| 598 | // systrace trace_marker counter events. |
| 599 | Counters counters_; |
Primiano Tucci | 5cb84f8 | 2018-10-31 21:46:36 -0700 | [diff] [blame] | 600 | |
| 601 | SqlStats sql_stats_; |
Lalit Maganti | 6e9c55e | 2018-11-29 12:00:39 +0000 | [diff] [blame] | 602 | |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 603 | // These are instantaneous events in the trace. They have no duration |
| 604 | // and do not have a value that make sense to track over time. |
| 605 | // e.g. signal events |
| 606 | Instants instants_; |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 607 | |
| 608 | // Raw events are every ftrace event in the trace. The raw event includes |
| 609 | // the timestamp and the pid. The args for the raw event will be in the |
| 610 | // args table. This table can be used to generate a text version of the |
| 611 | // trace. |
| 612 | RawEvents raw_events_; |
Primiano Tucci | 2c761ef | 2019-01-07 20:20:46 +0000 | [diff] [blame] | 613 | AndroidLogs android_log_; |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 614 | }; |
| 615 | |
| 616 | } // namespace trace_processor |
| 617 | } // namespace perfetto |
| 618 | |
| 619 | #endif // SRC_TRACE_PROCESSOR_TRACE_STORAGE_H_ |