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> |
| 25 | #include <vector> |
| 26 | |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 27 | #include "perfetto/base/logging.h" |
Primiano Tucci | 2da5d2e | 2018-08-10 14:23:31 +0100 | [diff] [blame] | 28 | #include "perfetto/base/string_view.h" |
Hector Dearman | c833993 | 2018-08-10 11:22:46 +0100 | [diff] [blame] | 29 | #include "perfetto/base/utils.h" |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 30 | |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 31 | namespace perfetto { |
| 32 | namespace trace_processor { |
| 33 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 34 | // UniquePid is an offset into |unique_processes_|. This is necessary because |
| 35 | // Unix pids are reused and thus not guaranteed to be unique over a long |
| 36 | // period of time. |
| 37 | using UniquePid = uint32_t; |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 38 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 39 | // UniqueTid is an offset into |unique_threads_|. Necessary because tids can |
| 40 | // be reused. |
| 41 | using UniqueTid = uint32_t; |
| 42 | |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 43 | // StringId is an offset into |string_pool_|. |
| 44 | using StringId = size_t; |
| 45 | |
Isabelle Taylor | 54ce705 | 2018-10-01 14:00:15 +0100 | [diff] [blame] | 46 | enum RefType { kNoRef = 0, kUTID = 1, kCPU_ID = 2, kIrq = 3, kSoftIrq = 4 }; |
Isabelle Taylor | 14674d4 | 2018-09-07 11:33:11 +0100 | [diff] [blame] | 47 | |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 48 | // Stores a data inside a trace file in a columnar form. This makes it efficient |
| 49 | // to read or search across a single field of the trace (e.g. all the thread |
| 50 | // names for a given CPU). |
| 51 | class TraceStorage { |
| 52 | public: |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 53 | TraceStorage(); |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 54 | TraceStorage(const TraceStorage&) = delete; |
| 55 | |
| 56 | virtual ~TraceStorage(); |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 57 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 58 | struct Stats { |
| 59 | uint64_t mismatched_sched_switch_tids_ = 0; |
| 60 | }; |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 61 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 62 | // Information about a unique process seen in a trace. |
| 63 | struct Process { |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 64 | explicit Process(uint32_t p) : pid(p) {} |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 65 | uint64_t start_ns = 0; |
| 66 | uint64_t end_ns = 0; |
| 67 | StringId name_id = 0; |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 68 | uint32_t pid = 0; |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | // Information about a unique thread seen in a trace. |
| 72 | struct Thread { |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 73 | explicit Thread(uint32_t t) : tid(t) {} |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 74 | uint64_t start_ns = 0; |
| 75 | uint64_t end_ns = 0; |
| 76 | StringId name_id = 0; |
| 77 | UniquePid upid = 0; |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 78 | uint32_t tid = 0; |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 79 | }; |
Isabelle Taylor | 3dd366c | 2018-06-22 16:21:41 +0100 | [diff] [blame] | 80 | |
Lalit Maganti | ff69c11 | 2018-09-24 12:07:47 +0100 | [diff] [blame] | 81 | class Slices { |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 82 | public: |
Lalit Maganti | fde2904 | 2018-10-04 13:28:52 +0100 | [diff] [blame^] | 83 | inline size_t AddSlice(uint32_t cpu, |
| 84 | uint64_t start_ns, |
| 85 | uint64_t duration_ns, |
| 86 | UniqueTid utid) { |
Lalit Maganti | ff69c11 | 2018-09-24 12:07:47 +0100 | [diff] [blame] | 87 | cpus_.emplace_back(cpu); |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 88 | start_ns_.emplace_back(start_ns); |
| 89 | durations_.emplace_back(duration_ns); |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 90 | utids_.emplace_back(utid); |
Lalit Maganti | fde2904 | 2018-10-04 13:28:52 +0100 | [diff] [blame^] | 91 | return slice_count() - 1; |
| 92 | } |
| 93 | |
| 94 | void set_duration(size_t index, uint64_t duration_ns) { |
| 95 | durations_[index] = duration_ns; |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 96 | } |
| 97 | |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 98 | size_t slice_count() const { return start_ns_.size(); } |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 99 | |
Lalit Maganti | ff69c11 | 2018-09-24 12:07:47 +0100 | [diff] [blame] | 100 | const std::deque<uint32_t>& cpus() const { return cpus_; } |
| 101 | |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 102 | const std::deque<uint64_t>& start_ns() const { return start_ns_; } |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 103 | |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 104 | const std::deque<uint64_t>& durations() const { return durations_; } |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 105 | |
Isabelle Taylor | 68e4219 | 2018-06-19 16:19:31 +0100 | [diff] [blame] | 106 | const std::deque<UniqueTid>& utids() const { return utids_; } |
| 107 | |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 108 | private: |
Hector Dearman | 947f12a | 2018-09-11 16:50:36 +0100 | [diff] [blame] | 109 | // 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] | 110 | // in the trace for the CPU). |
Lalit Maganti | ff69c11 | 2018-09-24 12:07:47 +0100 | [diff] [blame] | 111 | std::deque<uint32_t> cpus_; |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 112 | std::deque<uint64_t> start_ns_; |
| 113 | std::deque<uint64_t> durations_; |
Isabelle Taylor | 68e4219 | 2018-06-19 16:19:31 +0100 | [diff] [blame] | 114 | std::deque<UniqueTid> utids_; |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 115 | }; |
Isabelle Taylor | 68e4219 | 2018-06-19 16:19:31 +0100 | [diff] [blame] | 116 | |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 117 | class NestableSlices { |
| 118 | public: |
| 119 | inline void AddSlice(uint64_t start_ns, |
| 120 | uint64_t duration_ns, |
| 121 | UniqueTid utid, |
| 122 | StringId cat, |
| 123 | StringId name, |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 124 | uint8_t depth, |
| 125 | uint64_t stack_id, |
| 126 | uint64_t parent_stack_id) { |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 127 | start_ns_.emplace_back(start_ns); |
| 128 | durations_.emplace_back(duration_ns); |
| 129 | utids_.emplace_back(utid); |
| 130 | cats_.emplace_back(cat); |
| 131 | names_.emplace_back(name); |
| 132 | depths_.emplace_back(depth); |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 133 | stack_ids_.emplace_back(stack_id); |
| 134 | parent_stack_ids_.emplace_back(parent_stack_id); |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | size_t slice_count() const { return start_ns_.size(); } |
| 138 | const std::deque<uint64_t>& start_ns() const { return start_ns_; } |
| 139 | const std::deque<uint64_t>& durations() const { return durations_; } |
| 140 | const std::deque<UniqueTid>& utids() const { return utids_; } |
| 141 | const std::deque<StringId>& cats() const { return cats_; } |
| 142 | const std::deque<StringId>& names() const { return names_; } |
| 143 | const std::deque<uint8_t>& depths() const { return depths_; } |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 144 | const std::deque<uint64_t>& stack_ids() const { return stack_ids_; } |
| 145 | const std::deque<uint64_t>& parent_stack_ids() const { |
| 146 | return parent_stack_ids_; |
| 147 | } |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 148 | |
| 149 | private: |
| 150 | std::deque<uint64_t> start_ns_; |
| 151 | std::deque<uint64_t> durations_; |
| 152 | std::deque<UniqueTid> utids_; |
| 153 | std::deque<StringId> cats_; |
| 154 | std::deque<StringId> names_; |
| 155 | std::deque<uint8_t> depths_; |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 156 | std::deque<uint64_t> stack_ids_; |
| 157 | std::deque<uint64_t> parent_stack_ids_; |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 158 | }; |
| 159 | |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 160 | class Counters { |
| 161 | public: |
Lalit Maganti | fde2904 | 2018-10-04 13:28:52 +0100 | [diff] [blame^] | 162 | inline size_t AddCounter(uint64_t timestamp, |
| 163 | uint64_t duration, |
| 164 | StringId name_id, |
| 165 | double value, |
| 166 | double value_delta, |
| 167 | int64_t ref, |
| 168 | RefType type) { |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 169 | timestamps_.emplace_back(timestamp); |
| 170 | durations_.emplace_back(duration); |
| 171 | name_ids_.emplace_back(name_id); |
| 172 | values_.emplace_back(value); |
Isabelle Taylor | 31e0440 | 2018-09-19 12:13:25 +0100 | [diff] [blame] | 173 | value_deltas_.emplace_back(value_delta); |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 174 | refs_.emplace_back(ref); |
| 175 | types_.emplace_back(type); |
Lalit Maganti | fde2904 | 2018-10-04 13:28:52 +0100 | [diff] [blame^] | 176 | return counter_count() - 1; |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 177 | } |
Lalit Maganti | fde2904 | 2018-10-04 13:28:52 +0100 | [diff] [blame^] | 178 | |
| 179 | void set_duration(size_t index, uint64_t duration) { |
| 180 | durations_[index] = duration; |
| 181 | } |
| 182 | |
| 183 | void set_value_delta(size_t index, double value_delta) { |
| 184 | value_deltas_[index] = value_delta; |
| 185 | } |
| 186 | |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 187 | size_t counter_count() const { return timestamps_.size(); } |
| 188 | |
| 189 | const std::deque<uint64_t>& timestamps() const { return timestamps_; } |
| 190 | |
| 191 | const std::deque<uint64_t>& durations() const { return durations_; } |
| 192 | |
| 193 | const std::deque<StringId>& name_ids() const { return name_ids_; } |
| 194 | |
| 195 | const std::deque<double>& values() const { return values_; } |
| 196 | |
Isabelle Taylor | 31e0440 | 2018-09-19 12:13:25 +0100 | [diff] [blame] | 197 | const std::deque<double>& value_deltas() const { return value_deltas_; } |
| 198 | |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 199 | const std::deque<int64_t>& refs() const { return refs_; } |
| 200 | |
| 201 | const std::deque<RefType>& types() const { return types_; } |
| 202 | |
| 203 | private: |
| 204 | std::deque<uint64_t> timestamps_; |
| 205 | std::deque<uint64_t> durations_; |
| 206 | std::deque<StringId> name_ids_; |
| 207 | std::deque<double> values_; |
Isabelle Taylor | 31e0440 | 2018-09-19 12:13:25 +0100 | [diff] [blame] | 208 | std::deque<double> value_deltas_; |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 209 | std::deque<int64_t> refs_; |
| 210 | std::deque<RefType> types_; |
| 211 | }; |
| 212 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 213 | void ResetStorage(); |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 214 | |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 215 | UniqueTid AddEmptyThread(uint32_t tid) { |
| 216 | unique_threads_.emplace_back(tid); |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 217 | return static_cast<UniqueTid>(unique_threads_.size() - 1); |
| 218 | } |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 219 | |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 220 | UniquePid AddEmptyProcess(uint32_t pid) { |
| 221 | unique_processes_.emplace_back(pid); |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 222 | return static_cast<UniquePid>(unique_processes_.size() - 1); |
| 223 | } |
Isabelle Taylor | 3dd366c | 2018-06-22 16:21:41 +0100 | [diff] [blame] | 224 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 225 | void AddMismatchedSchedSwitch() { ++stats_.mismatched_sched_switch_tids_; } |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 226 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 227 | // Return an unqiue identifier for the contents of each string. |
| 228 | // The string is copied internally and can be destroyed after this called. |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 229 | // Virtual for testing. |
| 230 | virtual StringId InternString(base::StringView); |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 231 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 232 | Process* GetMutableProcess(UniquePid upid) { |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 233 | PERFETTO_DCHECK(upid > 0 && upid < unique_processes_.size()); |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 234 | return &unique_processes_[upid]; |
| 235 | } |
Isabelle Taylor | 3dd366c | 2018-06-22 16:21:41 +0100 | [diff] [blame] | 236 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 237 | Thread* GetMutableThread(UniqueTid utid) { |
Florian Mayer | a1aaec2 | 2018-09-19 17:02:26 +0100 | [diff] [blame] | 238 | PERFETTO_DCHECK(utid < unique_threads_.size()); |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 239 | return &unique_threads_[utid]; |
| 240 | } |
Isabelle Taylor | 3dd366c | 2018-06-22 16:21:41 +0100 | [diff] [blame] | 241 | |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 242 | // Reading methods. |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 243 | const std::string& GetString(StringId id) const { |
| 244 | PERFETTO_DCHECK(id < string_pool_.size()); |
| 245 | return string_pool_[id]; |
| 246 | } |
| 247 | |
Lalit Maganti | e9d4053 | 2018-06-29 13:15:06 +0100 | [diff] [blame] | 248 | const Process& GetProcess(UniquePid upid) const { |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 249 | PERFETTO_DCHECK(upid > 0 && upid < unique_processes_.size()); |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 250 | return unique_processes_[upid]; |
| 251 | } |
| 252 | |
Lalit Maganti | e9d4053 | 2018-06-29 13:15:06 +0100 | [diff] [blame] | 253 | const Thread& GetThread(UniqueTid utid) const { |
Lalit Maganti | 1f64cfa | 2018-09-18 13:20:02 +0100 | [diff] [blame] | 254 | // Allow utid == 0 for idle thread retrieval. |
Florian Mayer | a1aaec2 | 2018-09-19 17:02:26 +0100 | [diff] [blame] | 255 | PERFETTO_DCHECK(utid < unique_threads_.size()); |
Isabelle Taylor | 68e4219 | 2018-06-19 16:19:31 +0100 | [diff] [blame] | 256 | return unique_threads_[utid]; |
| 257 | } |
| 258 | |
Lalit Maganti | ff69c11 | 2018-09-24 12:07:47 +0100 | [diff] [blame] | 259 | const Slices& slices() const { return slices_; } |
Lalit Maganti | fde2904 | 2018-10-04 13:28:52 +0100 | [diff] [blame^] | 260 | Slices* mutable_slices() { return &slices_; } |
| 261 | |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 262 | const NestableSlices& nestable_slices() const { return nestable_slices_; } |
| 263 | NestableSlices* mutable_nestable_slices() { return &nestable_slices_; } |
| 264 | |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 265 | const Counters& counters() const { return counters_; } |
| 266 | Counters* mutable_counters() { return &counters_; } |
Isabelle Taylor | 14674d4 | 2018-09-07 11:33:11 +0100 | [diff] [blame] | 267 | |
Isabelle Taylor | e7003fb | 2018-07-17 11:39:01 +0100 | [diff] [blame] | 268 | // |unique_processes_| always contains at least 1 element becuase the 0th ID |
| 269 | // is reserved to indicate an invalid process. |
| 270 | size_t process_count() const { return unique_processes_.size() - 1; } |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 271 | |
Isabelle Taylor | e7003fb | 2018-07-17 11:39:01 +0100 | [diff] [blame] | 272 | // |unique_threads_| always contains at least 1 element becuase the 0th ID |
| 273 | // is reserved to indicate an invalid thread. |
| 274 | size_t thread_count() const { return unique_threads_.size() - 1; } |
| 275 | |
Hector Dearman | 1232336 | 2018-08-09 16:09:28 +0100 | [diff] [blame] | 276 | // Number of interned strings in the pool. Includes the empty string w/ ID=0. |
| 277 | size_t string_count() const { return string_pool_.size(); } |
| 278 | |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 279 | private: |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 280 | TraceStorage& operator=(const TraceStorage&) = default; |
| 281 | |
Primiano Tucci | 2da5d2e | 2018-08-10 14:23:31 +0100 | [diff] [blame] | 282 | using StringHash = uint64_t; |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 283 | |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 284 | // Metadata counters for events being added. |
| 285 | Stats stats_; |
| 286 | |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 287 | // One entry for each CPU in the trace. |
Lalit Maganti | ff69c11 | 2018-09-24 12:07:47 +0100 | [diff] [blame] | 288 | Slices slices_; |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 289 | |
| 290 | // One entry for each unique string in the trace. |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 291 | std::deque<std::string> string_pool_; |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 292 | |
| 293 | // One entry for each unique string in the trace. |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 294 | std::unordered_map<StringHash, StringId> string_index_; |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 295 | |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 296 | // One entry for each UniquePid, with UniquePid as the index. |
Isabelle Taylor | 3dd366c | 2018-06-22 16:21:41 +0100 | [diff] [blame] | 297 | std::deque<Process> unique_processes_; |
Isabelle Taylor | 68e4219 | 2018-06-19 16:19:31 +0100 | [diff] [blame] | 298 | |
Isabelle Taylor | 68e4219 | 2018-06-19 16:19:31 +0100 | [diff] [blame] | 299 | // One entry for each UniqueTid, with UniqueTid as the index. |
Isabelle Taylor | 3dd366c | 2018-06-22 16:21:41 +0100 | [diff] [blame] | 300 | std::deque<Thread> unique_threads_; |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 301 | |
| 302 | // Slices coming from userspace events (e.g. Chromium TRACE_EVENT macros). |
| 303 | NestableSlices nestable_slices_; |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 304 | |
| 305 | // Counter events from the trace. This includes CPU frequency events as well |
| 306 | // systrace trace_marker counter events. |
| 307 | Counters counters_; |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 308 | }; |
| 309 | |
| 310 | } // namespace trace_processor |
| 311 | } // namespace perfetto |
| 312 | |
| 313 | #endif // SRC_TRACE_PROCESSOR_TRACE_STORAGE_H_ |