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" |
Eric Seckler | 83dcc8c | 2019-08-21 12:18:43 +0100 | [diff] [blame] | 29 | #include "perfetto/base/time.h" |
Primiano Tucci | 2c5488f | 2019-06-01 03:27:28 +0100 | [diff] [blame] | 30 | #include "perfetto/ext/base/hash.h" |
| 31 | #include "perfetto/ext/base/optional.h" |
| 32 | #include "perfetto/ext/base/string_view.h" |
Primiano Tucci | 2c5488f | 2019-06-01 03:27:28 +0100 | [diff] [blame] | 33 | #include "perfetto/ext/base/utils.h" |
Lalit Maganti | b0b53ee | 2019-01-24 17:53:39 +0000 | [diff] [blame] | 34 | #include "src/trace_processor/ftrace_utils.h" |
Mikhail Khokhlov | e466c00 | 2019-05-23 13:33:33 +0100 | [diff] [blame] | 35 | #include "src/trace_processor/metadata.h" |
Primiano Tucci | 0e38a14 | 2019-01-07 20:51:09 +0000 | [diff] [blame] | 36 | #include "src/trace_processor/stats.h" |
Lalit Maganti | 5c45431 | 2019-04-08 12:11:17 +0100 | [diff] [blame] | 37 | #include "src/trace_processor/string_pool.h" |
Ioannis Ilkos | e0b47f5 | 2019-09-18 11:14:57 +0100 | [diff] [blame] | 38 | #include "src/trace_processor/tables/profiler_tables.h" |
Lalit Maganti | 20539c2 | 2019-09-04 12:36:10 +0100 | [diff] [blame] | 39 | #include "src/trace_processor/tables/slice_tables.h" |
| 40 | #include "src/trace_processor/tables/track_tables.h" |
Mikhail Khokhlov | 85a0dd0 | 2019-05-17 14:22:28 +0100 | [diff] [blame] | 41 | #include "src/trace_processor/variadic.h" |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 42 | |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 43 | namespace perfetto { |
| 44 | namespace trace_processor { |
| 45 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 46 | // UniquePid is an offset into |unique_processes_|. This is necessary because |
| 47 | // Unix pids are reused and thus not guaranteed to be unique over a long |
| 48 | // period of time. |
| 49 | using UniquePid = uint32_t; |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 50 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 51 | // UniqueTid is an offset into |unique_threads_|. Necessary because tids can |
| 52 | // be reused. |
| 53 | using UniqueTid = uint32_t; |
| 54 | |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 55 | // StringId is an offset into |string_pool_|. |
Lalit Maganti | 5c45431 | 2019-04-08 12:11:17 +0100 | [diff] [blame] | 56 | using StringId = StringPool::Id; |
Lalit Maganti | 1a2936f | 2019-08-29 17:42:33 +0100 | [diff] [blame] | 57 | static const StringId kNullStringId = StringId(0); |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 58 | |
Lalit Maganti | 5ea9e93 | 2018-11-30 14:19:39 +0000 | [diff] [blame] | 59 | // Identifiers for all the tables in the database. |
| 60 | enum TableId : uint8_t { |
| 61 | // Intentionally don't have TableId == 0 so that RowId == 0 can refer to an |
| 62 | // invalid row id. |
Lalit Maganti | 8320e6d | 2019-03-14 18:49:33 +0000 | [diff] [blame] | 63 | kCounterValues = 1, |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 64 | kRawEvents = 2, |
Lalit Maganti | 66ed7ad | 2019-01-11 16:47:26 +0000 | [diff] [blame] | 65 | kInstants = 3, |
Isabelle Taylor | b9222c3 | 2019-01-31 10:58:37 +0000 | [diff] [blame] | 66 | kSched = 4, |
Eric Seckler | 70cc442 | 2019-05-28 16:00:23 +0100 | [diff] [blame] | 67 | kNestableSlices = 5, |
Ryan Savitski | 51413ad | 2019-07-09 14:25:21 +0100 | [diff] [blame] | 68 | kMetadataTable = 6, |
Lalit Maganti | 53bdbb2 | 2019-09-25 11:11:18 +0100 | [diff] [blame] | 69 | kTrack = 7, |
Lalit Maganti | 5ea9e93 | 2018-11-30 14:19:39 +0000 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | // The top 8 bits are set to the TableId and the bottom 32 to the row of the |
| 73 | // table. |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 74 | using RowId = int64_t; |
Lalit Maganti | 5ea9e93 | 2018-11-30 14:19:39 +0000 | [diff] [blame] | 75 | static const RowId kInvalidRowId = 0; |
| 76 | |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 77 | using ArgSetId = uint32_t; |
| 78 | static const ArgSetId kInvalidArgSetId = 0; |
| 79 | |
Eric Seckler | 5703ede | 2019-07-10 10:13:02 +0100 | [diff] [blame] | 80 | using TrackId = uint32_t; |
| 81 | |
Lalit Maganti | 21b2163 | 2019-09-28 16:50:23 +0100 | [diff] [blame] | 82 | enum class RefType { |
Primiano Tucci | 5403e4f | 2018-11-27 10:07:03 +0000 | [diff] [blame] | 83 | kRefNoRef = 0, |
| 84 | kRefUtid = 1, |
| 85 | kRefCpuId = 2, |
| 86 | kRefIrq = 3, |
| 87 | kRefSoftIrq = 4, |
| 88 | kRefUpid = 5, |
Sidath Senanayake | 1f5f93a | 2019-06-06 22:24:15 +0100 | [diff] [blame] | 89 | kRefGpuId = 6, |
Eric Seckler | 5703ede | 2019-07-10 10:13:02 +0100 | [diff] [blame] | 90 | kRefTrack = 7, |
Primiano Tucci | 5403e4f | 2018-11-27 10:07:03 +0000 | [diff] [blame] | 91 | kRefMax |
Isabelle Taylor | a97c5f5 | 2018-10-23 17:36:12 +0100 | [diff] [blame] | 92 | }; |
Isabelle Taylor | 14674d4 | 2018-09-07 11:33:11 +0100 | [diff] [blame] | 93 | |
Eric Seckler | 972225e | 2019-04-18 11:07:12 +0100 | [diff] [blame] | 94 | const std::vector<const char*>& GetRefTypeStringMap(); |
| 95 | |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 96 | // Stores a data inside a trace file in a columnar form. This makes it efficient |
| 97 | // to read or search across a single field of the trace (e.g. all the thread |
| 98 | // names for a given CPU). |
| 99 | class TraceStorage { |
| 100 | public: |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 101 | TraceStorage(); |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 102 | |
| 103 | virtual ~TraceStorage(); |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 104 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 105 | // Information about a unique process seen in a trace. |
| 106 | struct Process { |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 107 | explicit Process(uint32_t p) : pid(p) {} |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 108 | int64_t start_ns = 0; |
Lalit Maganti | 637589a | 2019-07-04 17:25:29 +0100 | [diff] [blame] | 109 | int64_t end_ns = 0; |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 110 | StringId name_id = 0; |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 111 | uint32_t pid = 0; |
Lalit Maganti | 369b057 | 2019-07-11 15:35:09 +0100 | [diff] [blame] | 112 | base::Optional<UniquePid> parent_upid; |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 113 | }; |
| 114 | |
| 115 | // Information about a unique thread seen in a trace. |
| 116 | struct Thread { |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 117 | explicit Thread(uint32_t t) : tid(t) {} |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 118 | int64_t start_ns = 0; |
Lalit Maganti | b5bd233 | 2019-06-06 14:20:47 +0100 | [diff] [blame] | 119 | int64_t end_ns = 0; |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 120 | StringId name_id = 0; |
Lalit Maganti | 770886a | 2018-11-16 17:40:21 +0000 | [diff] [blame] | 121 | base::Optional<UniquePid> upid; |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 122 | uint32_t tid = 0; |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 123 | }; |
Isabelle Taylor | 3dd366c | 2018-06-22 16:21:41 +0100 | [diff] [blame] | 124 | |
Lalit Maganti | 6e9c55e | 2018-11-29 12:00:39 +0000 | [diff] [blame] | 125 | // Generic key value storage which can be referenced by other tables. |
| 126 | class Args { |
| 127 | public: |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 128 | struct Arg { |
| 129 | StringId flat_key = 0; |
| 130 | StringId key = 0; |
| 131 | Variadic value = Variadic::Integer(0); |
| 132 | |
| 133 | // This is only used by the arg tracker and so is not part of the hash. |
| 134 | RowId row_id = 0; |
| 135 | }; |
| 136 | |
| 137 | struct ArgHasher { |
| 138 | uint64_t operator()(const Arg& arg) const noexcept { |
Lalit Maganti | 1f46474 | 2019-02-28 13:49:31 +0000 | [diff] [blame] | 139 | base::Hash hash; |
| 140 | hash.Update(arg.key); |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 141 | // We don't hash arg.flat_key because it's a subsequence of arg.key. |
| 142 | switch (arg.value.type) { |
| 143 | case Variadic::Type::kInt: |
Lalit Maganti | 1f46474 | 2019-02-28 13:49:31 +0000 | [diff] [blame] | 144 | hash.Update(arg.value.int_value); |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 145 | break; |
Eric Seckler | c93823e | 2019-06-03 16:49:19 +0100 | [diff] [blame] | 146 | case Variadic::Type::kUint: |
| 147 | hash.Update(arg.value.uint_value); |
| 148 | break; |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 149 | case Variadic::Type::kString: |
Lalit Maganti | 1f46474 | 2019-02-28 13:49:31 +0000 | [diff] [blame] | 150 | hash.Update(arg.value.string_value); |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 151 | break; |
| 152 | case Variadic::Type::kReal: |
Lalit Maganti | 1f46474 | 2019-02-28 13:49:31 +0000 | [diff] [blame] | 153 | hash.Update(arg.value.real_value); |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 154 | break; |
Eric Seckler | c93823e | 2019-06-03 16:49:19 +0100 | [diff] [blame] | 155 | case Variadic::Type::kPointer: |
| 156 | hash.Update(arg.value.pointer_value); |
| 157 | break; |
| 158 | case Variadic::Type::kBool: |
| 159 | hash.Update(arg.value.bool_value); |
| 160 | break; |
| 161 | case Variadic::Type::kJson: |
| 162 | hash.Update(arg.value.json_value); |
| 163 | break; |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 164 | } |
Lalit Maganti | 1f46474 | 2019-02-28 13:49:31 +0000 | [diff] [blame] | 165 | return hash.digest(); |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 166 | } |
| 167 | }; |
| 168 | |
| 169 | const std::deque<ArgSetId>& set_ids() const { return set_ids_; } |
Lalit Maganti | 5ea9e93 | 2018-11-30 14:19:39 +0000 | [diff] [blame] | 170 | const std::deque<StringId>& flat_keys() const { return flat_keys_; } |
| 171 | const std::deque<StringId>& keys() const { return keys_; } |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 172 | const std::deque<Variadic>& arg_values() const { return arg_values_; } |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 173 | uint32_t args_count() const { |
| 174 | return static_cast<uint32_t>(set_ids_.size()); |
Lalit Maganti | 79472be | 2018-12-04 13:41:27 +0000 | [diff] [blame] | 175 | } |
Lalit Maganti | 6e9c55e | 2018-11-29 12:00:39 +0000 | [diff] [blame] | 176 | |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 177 | ArgSetId AddArgSet(const std::vector<Arg>& args, |
| 178 | uint32_t begin, |
| 179 | uint32_t end) { |
Lalit Maganti | 1f46474 | 2019-02-28 13:49:31 +0000 | [diff] [blame] | 180 | base::Hash hash; |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 181 | for (uint32_t i = begin; i < end; i++) { |
Lalit Maganti | 1f46474 | 2019-02-28 13:49:31 +0000 | [diff] [blame] | 182 | hash.Update(ArgHasher()(args[i])); |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 183 | } |
Lalit Maganti | 5ea9e93 | 2018-11-30 14:19:39 +0000 | [diff] [blame] | 184 | |
Lalit Maganti | 1f46474 | 2019-02-28 13:49:31 +0000 | [diff] [blame] | 185 | ArgSetHash digest = hash.digest(); |
| 186 | auto it = arg_row_for_hash_.find(digest); |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 187 | if (it != arg_row_for_hash_.end()) { |
| 188 | return set_ids_[it->second]; |
| 189 | } |
| 190 | |
| 191 | // The +1 ensures that nothing has an id == kInvalidArgSetId == 0. |
| 192 | ArgSetId id = static_cast<uint32_t>(arg_row_for_hash_.size()) + 1; |
Lalit Maganti | 1f46474 | 2019-02-28 13:49:31 +0000 | [diff] [blame] | 193 | arg_row_for_hash_.emplace(digest, args_count()); |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 194 | for (uint32_t i = begin; i < end; i++) { |
| 195 | const auto& arg = args[i]; |
| 196 | set_ids_.emplace_back(id); |
| 197 | flat_keys_.emplace_back(arg.flat_key); |
| 198 | keys_.emplace_back(arg.key); |
| 199 | arg_values_.emplace_back(arg.value); |
| 200 | } |
| 201 | return id; |
Lalit Maganti | 6e9c55e | 2018-11-29 12:00:39 +0000 | [diff] [blame] | 202 | } |
| 203 | |
Lalit Maganti | 5ea9e93 | 2018-11-30 14:19:39 +0000 | [diff] [blame] | 204 | private: |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 205 | using ArgSetHash = uint64_t; |
| 206 | |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 207 | std::deque<ArgSetId> set_ids_; |
Lalit Maganti | 5ea9e93 | 2018-11-30 14:19:39 +0000 | [diff] [blame] | 208 | std::deque<StringId> flat_keys_; |
| 209 | std::deque<StringId> keys_; |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 210 | std::deque<Variadic> arg_values_; |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 211 | |
| 212 | std::unordered_map<ArgSetHash, uint32_t> arg_row_for_hash_; |
Lalit Maganti | 6e9c55e | 2018-11-29 12:00:39 +0000 | [diff] [blame] | 213 | }; |
| 214 | |
Lalit Maganti | d11d3e0 | 2019-07-26 12:32:09 +0530 | [diff] [blame] | 215 | class Tracks { |
| 216 | public: |
| 217 | inline uint32_t AddTrack(StringId name) { |
| 218 | names_.emplace_back(name); |
| 219 | return track_count() - 1; |
| 220 | } |
| 221 | |
| 222 | uint32_t track_count() const { |
| 223 | return static_cast<uint32_t>(names_.size()); |
| 224 | } |
| 225 | |
| 226 | const std::deque<StringId>& names() const { return names_; } |
| 227 | |
| 228 | private: |
| 229 | std::deque<StringId> names_; |
| 230 | }; |
| 231 | |
Mikael Pessa | 803090c | 2019-08-23 16:03:34 -0700 | [diff] [blame] | 232 | class GpuContexts { |
| 233 | public: |
| 234 | inline void AddGpuContext(uint64_t context_id, |
| 235 | UniquePid upid, |
| 236 | uint32_t priority) { |
| 237 | context_ids_.emplace_back(context_id); |
| 238 | upids_.emplace_back(upid); |
| 239 | priorities_.emplace_back(priority); |
| 240 | } |
| 241 | |
| 242 | uint32_t gpu_context_count() const { |
| 243 | return static_cast<uint32_t>(context_ids_.size()); |
| 244 | } |
| 245 | |
| 246 | const std::deque<uint64_t>& context_ids() const { return context_ids_; } |
| 247 | const std::deque<UniquePid>& upids() const { return upids_; } |
| 248 | const std::deque<uint32_t>& priorities() const { return priorities_; } |
| 249 | |
| 250 | private: |
| 251 | std::deque<uint64_t> context_ids_; |
| 252 | std::deque<UniquePid> upids_; |
| 253 | std::deque<uint32_t> priorities_; |
| 254 | }; |
| 255 | |
Lalit Maganti | ff69c11 | 2018-09-24 12:07:47 +0100 | [diff] [blame] | 256 | class Slices { |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 257 | public: |
Lalit Maganti | fde2904 | 2018-10-04 13:28:52 +0100 | [diff] [blame] | 258 | inline size_t AddSlice(uint32_t cpu, |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 259 | int64_t start_ns, |
| 260 | int64_t duration_ns, |
Lalit Maganti | b0b53ee | 2019-01-24 17:53:39 +0000 | [diff] [blame] | 261 | UniqueTid utid, |
| 262 | ftrace_utils::TaskState end_state, |
| 263 | int32_t priority) { |
Lalit Maganti | ff69c11 | 2018-09-24 12:07:47 +0100 | [diff] [blame] | 264 | cpus_.emplace_back(cpu); |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 265 | start_ns_.emplace_back(start_ns); |
| 266 | durations_.emplace_back(duration_ns); |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 267 | utids_.emplace_back(utid); |
Lalit Maganti | b0b53ee | 2019-01-24 17:53:39 +0000 | [diff] [blame] | 268 | end_states_.emplace_back(end_state); |
| 269 | priorities_.emplace_back(priority); |
Lalit Maganti | 5863893 | 2019-01-31 10:48:26 +0000 | [diff] [blame] | 270 | |
| 271 | if (utid >= rows_for_utids_.size()) |
| 272 | rows_for_utids_.resize(utid + 1); |
| 273 | rows_for_utids_[utid].emplace_back(slice_count() - 1); |
Lalit Maganti | fde2904 | 2018-10-04 13:28:52 +0100 | [diff] [blame] | 274 | return slice_count() - 1; |
| 275 | } |
| 276 | |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 277 | void set_duration(size_t index, int64_t duration_ns) { |
Lalit Maganti | fde2904 | 2018-10-04 13:28:52 +0100 | [diff] [blame] | 278 | durations_[index] = duration_ns; |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 279 | } |
| 280 | |
Lalit Maganti | b0b53ee | 2019-01-24 17:53:39 +0000 | [diff] [blame] | 281 | void set_end_state(size_t index, ftrace_utils::TaskState end_state) { |
| 282 | end_states_[index] = end_state; |
| 283 | } |
| 284 | |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 285 | size_t slice_count() const { return start_ns_.size(); } |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 286 | |
Lalit Maganti | ff69c11 | 2018-09-24 12:07:47 +0100 | [diff] [blame] | 287 | const std::deque<uint32_t>& cpus() const { return cpus_; } |
| 288 | |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 289 | const std::deque<int64_t>& start_ns() const { return start_ns_; } |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 290 | |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 291 | const std::deque<int64_t>& durations() const { return durations_; } |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 292 | |
Isabelle Taylor | 68e4219 | 2018-06-19 16:19:31 +0100 | [diff] [blame] | 293 | const std::deque<UniqueTid>& utids() const { return utids_; } |
| 294 | |
Lalit Maganti | b0b53ee | 2019-01-24 17:53:39 +0000 | [diff] [blame] | 295 | const std::deque<ftrace_utils::TaskState>& end_state() const { |
| 296 | return end_states_; |
| 297 | } |
| 298 | |
| 299 | const std::deque<int32_t>& priorities() const { return priorities_; } |
| 300 | |
Lalit Maganti | 5863893 | 2019-01-31 10:48:26 +0000 | [diff] [blame] | 301 | const std::deque<std::vector<uint32_t>>& rows_for_utids() const { |
Lalit Maganti | f0f09c3 | 2019-01-18 17:29:31 +0000 | [diff] [blame] | 302 | return rows_for_utids_; |
| 303 | } |
| 304 | |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 305 | private: |
Hector Dearman | 947f12a | 2018-09-11 16:50:36 +0100 | [diff] [blame] | 306 | // 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] | 307 | // in the trace for the CPU). |
Lalit Maganti | ff69c11 | 2018-09-24 12:07:47 +0100 | [diff] [blame] | 308 | std::deque<uint32_t> cpus_; |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 309 | std::deque<int64_t> start_ns_; |
| 310 | std::deque<int64_t> durations_; |
Isabelle Taylor | 68e4219 | 2018-06-19 16:19:31 +0100 | [diff] [blame] | 311 | std::deque<UniqueTid> utids_; |
Lalit Maganti | b0b53ee | 2019-01-24 17:53:39 +0000 | [diff] [blame] | 312 | std::deque<ftrace_utils::TaskState> end_states_; |
| 313 | std::deque<int32_t> priorities_; |
Lalit Maganti | 5863893 | 2019-01-31 10:48:26 +0000 | [diff] [blame] | 314 | |
| 315 | // One row per utid. |
| 316 | std::deque<std::vector<uint32_t>> rows_for_utids_; |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 317 | }; |
Isabelle Taylor | 68e4219 | 2018-06-19 16:19:31 +0100 | [diff] [blame] | 318 | |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 319 | class NestableSlices { |
| 320 | public: |
Eric Seckler | 70cc442 | 2019-05-28 16:00:23 +0100 | [diff] [blame] | 321 | inline uint32_t AddSlice(int64_t start_ns, |
| 322 | int64_t duration_ns, |
Lalit Maganti | 21b2163 | 2019-09-28 16:50:23 +0100 | [diff] [blame] | 323 | TrackId track_id, |
Eric Seckler | 70cc442 | 2019-05-28 16:00:23 +0100 | [diff] [blame] | 324 | int64_t ref, |
| 325 | RefType type, |
Lalit Maganti | 81a02cd | 2019-07-12 17:05:11 +0100 | [diff] [blame] | 326 | StringId category, |
Eric Seckler | 70cc442 | 2019-05-28 16:00:23 +0100 | [diff] [blame] | 327 | StringId name, |
| 328 | uint8_t depth, |
| 329 | int64_t stack_id, |
| 330 | int64_t parent_stack_id) { |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 331 | start_ns_.emplace_back(start_ns); |
| 332 | durations_.emplace_back(duration_ns); |
Lalit Maganti | 21b2163 | 2019-09-28 16:50:23 +0100 | [diff] [blame] | 333 | track_id_.emplace_back(track_id); |
Eric Seckler | 972225e | 2019-04-18 11:07:12 +0100 | [diff] [blame] | 334 | refs_.emplace_back(ref); |
| 335 | types_.emplace_back(type); |
Lalit Maganti | 81a02cd | 2019-07-12 17:05:11 +0100 | [diff] [blame] | 336 | categories_.emplace_back(category); |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 337 | names_.emplace_back(name); |
| 338 | depths_.emplace_back(depth); |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 339 | stack_ids_.emplace_back(stack_id); |
| 340 | parent_stack_ids_.emplace_back(parent_stack_id); |
Eric Seckler | 70cc442 | 2019-05-28 16:00:23 +0100 | [diff] [blame] | 341 | arg_set_ids_.emplace_back(kInvalidArgSetId); |
Lalit Maganti | 7b37bbf | 2018-11-09 15:58:54 +0000 | [diff] [blame] | 342 | return slice_count() - 1; |
| 343 | } |
| 344 | |
Eric Seckler | 70cc442 | 2019-05-28 16:00:23 +0100 | [diff] [blame] | 345 | void set_duration(uint32_t index, int64_t duration_ns) { |
Lalit Maganti | 7b37bbf | 2018-11-09 15:58:54 +0000 | [diff] [blame] | 346 | durations_[index] = duration_ns; |
| 347 | } |
| 348 | |
Eric Seckler | 70cc442 | 2019-05-28 16:00:23 +0100 | [diff] [blame] | 349 | void set_stack_id(uint32_t index, int64_t stack_id) { |
Lalit Maganti | 7b37bbf | 2018-11-09 15:58:54 +0000 | [diff] [blame] | 350 | stack_ids_[index] = stack_id; |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 351 | } |
| 352 | |
Eric Seckler | 70cc442 | 2019-05-28 16:00:23 +0100 | [diff] [blame] | 353 | void set_arg_set_id(uint32_t index, ArgSetId id) { |
| 354 | arg_set_ids_[index] = id; |
| 355 | } |
| 356 | |
| 357 | uint32_t slice_count() const { |
| 358 | return static_cast<uint32_t>(start_ns_.size()); |
| 359 | } |
| 360 | |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 361 | const std::deque<int64_t>& start_ns() const { return start_ns_; } |
| 362 | const std::deque<int64_t>& durations() const { return durations_; } |
Lalit Maganti | 21b2163 | 2019-09-28 16:50:23 +0100 | [diff] [blame] | 363 | const std::deque<TrackId>& track_id() const { return track_id_; } |
Eric Seckler | 972225e | 2019-04-18 11:07:12 +0100 | [diff] [blame] | 364 | const std::deque<int64_t>& refs() const { return refs_; } |
| 365 | const std::deque<RefType>& types() const { return types_; } |
Lalit Maganti | 81a02cd | 2019-07-12 17:05:11 +0100 | [diff] [blame] | 366 | const std::deque<StringId>& categories() const { return categories_; } |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 367 | const std::deque<StringId>& names() const { return names_; } |
| 368 | const std::deque<uint8_t>& depths() const { return depths_; } |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 369 | const std::deque<int64_t>& stack_ids() const { return stack_ids_; } |
| 370 | const std::deque<int64_t>& parent_stack_ids() const { |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 371 | return parent_stack_ids_; |
| 372 | } |
Eric Seckler | 70cc442 | 2019-05-28 16:00:23 +0100 | [diff] [blame] | 373 | const std::deque<ArgSetId>& arg_set_ids() const { return arg_set_ids_; } |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 374 | |
| 375 | private: |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 376 | std::deque<int64_t> start_ns_; |
| 377 | std::deque<int64_t> durations_; |
Lalit Maganti | 21b2163 | 2019-09-28 16:50:23 +0100 | [diff] [blame] | 378 | std::deque<TrackId> track_id_; |
Eric Seckler | 972225e | 2019-04-18 11:07:12 +0100 | [diff] [blame] | 379 | std::deque<int64_t> refs_; |
| 380 | std::deque<RefType> types_; |
Lalit Maganti | 81a02cd | 2019-07-12 17:05:11 +0100 | [diff] [blame] | 381 | std::deque<StringId> categories_; |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 382 | std::deque<StringId> names_; |
| 383 | std::deque<uint8_t> depths_; |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 384 | std::deque<int64_t> stack_ids_; |
| 385 | std::deque<int64_t> parent_stack_ids_; |
Eric Seckler | 70cc442 | 2019-05-28 16:00:23 +0100 | [diff] [blame] | 386 | std::deque<ArgSetId> arg_set_ids_; |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 387 | }; |
| 388 | |
Eric Seckler | d3b89d5 | 2019-07-10 15:36:29 +0100 | [diff] [blame] | 389 | class ThreadSlices { |
| 390 | public: |
| 391 | inline uint32_t AddThreadSlice(uint32_t slice_id, |
| 392 | int64_t thread_timestamp_ns, |
| 393 | int64_t thread_duration_ns, |
| 394 | int64_t thread_instruction_count, |
| 395 | int64_t thread_instruction_delta) { |
| 396 | slice_ids_.emplace_back(slice_id); |
| 397 | thread_timestamp_ns_.emplace_back(thread_timestamp_ns); |
| 398 | thread_duration_ns_.emplace_back(thread_duration_ns); |
| 399 | thread_instruction_counts_.emplace_back(thread_instruction_count); |
| 400 | thread_instruction_deltas_.emplace_back(thread_instruction_delta); |
| 401 | return slice_count() - 1; |
| 402 | } |
| 403 | |
Eric Seckler | c3430c6 | 2019-07-22 10:49:58 +0100 | [diff] [blame] | 404 | uint32_t slice_count() const { |
| 405 | return static_cast<uint32_t>(slice_ids_.size()); |
Eric Seckler | d3b89d5 | 2019-07-10 15:36:29 +0100 | [diff] [blame] | 406 | } |
| 407 | |
Eric Seckler | c3430c6 | 2019-07-22 10:49:58 +0100 | [diff] [blame] | 408 | const std::deque<uint32_t>& slice_ids() const { return slice_ids_; } |
| 409 | const std::deque<int64_t>& thread_timestamp_ns() const { |
| 410 | return thread_timestamp_ns_; |
| 411 | } |
| 412 | const std::deque<int64_t>& thread_duration_ns() const { |
| 413 | return thread_duration_ns_; |
| 414 | } |
| 415 | const std::deque<int64_t>& thread_instruction_counts() const { |
| 416 | return thread_instruction_counts_; |
| 417 | } |
| 418 | const std::deque<int64_t>& thread_instruction_deltas() const { |
| 419 | return thread_instruction_deltas_; |
| 420 | } |
| 421 | |
| 422 | base::Optional<uint32_t> FindRowForSliceId(uint32_t slice_id) const { |
| 423 | auto it = |
| 424 | std::lower_bound(slice_ids().begin(), slice_ids().end(), slice_id); |
| 425 | if (it != slice_ids().end() && *it == slice_id) { |
| 426 | return static_cast<uint32_t>(std::distance(slice_ids().begin(), it)); |
| 427 | } |
| 428 | return base::nullopt; |
| 429 | } |
| 430 | |
Eric Seckler | 54f30a3 | 2019-07-19 15:10:29 +0100 | [diff] [blame] | 431 | void UpdateThreadDeltasForSliceId(uint32_t slice_id, |
| 432 | int64_t end_thread_timestamp_ns, |
| 433 | int64_t end_thread_instruction_count) { |
Eric Seckler | c3430c6 | 2019-07-22 10:49:58 +0100 | [diff] [blame] | 434 | uint32_t row = *FindRowForSliceId(slice_id); |
| 435 | int64_t begin_ns = thread_timestamp_ns_[row]; |
| 436 | thread_duration_ns_[row] = end_thread_timestamp_ns - begin_ns; |
Eric Seckler | 54f30a3 | 2019-07-19 15:10:29 +0100 | [diff] [blame] | 437 | int64_t begin_ticount = thread_instruction_counts_[row]; |
| 438 | thread_instruction_deltas_[row] = |
| 439 | end_thread_instruction_count - begin_ticount; |
Eric Seckler | c3430c6 | 2019-07-22 10:49:58 +0100 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | private: |
| 443 | std::deque<uint32_t> slice_ids_; |
| 444 | std::deque<int64_t> thread_timestamp_ns_; |
| 445 | std::deque<int64_t> thread_duration_ns_; |
| 446 | std::deque<int64_t> thread_instruction_counts_; |
| 447 | std::deque<int64_t> thread_instruction_deltas_; |
| 448 | }; |
| 449 | |
| 450 | class VirtualTrackSlices { |
| 451 | public: |
| 452 | inline uint32_t AddVirtualTrackSlice(uint32_t slice_id, |
| 453 | int64_t thread_timestamp_ns, |
| 454 | int64_t thread_duration_ns, |
| 455 | int64_t thread_instruction_count, |
| 456 | int64_t thread_instruction_delta) { |
| 457 | slice_ids_.emplace_back(slice_id); |
| 458 | thread_timestamp_ns_.emplace_back(thread_timestamp_ns); |
| 459 | thread_duration_ns_.emplace_back(thread_duration_ns); |
| 460 | thread_instruction_counts_.emplace_back(thread_instruction_count); |
| 461 | thread_instruction_deltas_.emplace_back(thread_instruction_delta); |
| 462 | return slice_count() - 1; |
Eric Seckler | d3b89d5 | 2019-07-10 15:36:29 +0100 | [diff] [blame] | 463 | } |
| 464 | |
| 465 | uint32_t slice_count() const { |
| 466 | return static_cast<uint32_t>(slice_ids_.size()); |
| 467 | } |
| 468 | |
| 469 | const std::deque<uint32_t>& slice_ids() const { return slice_ids_; } |
| 470 | const std::deque<int64_t>& thread_timestamp_ns() const { |
| 471 | return thread_timestamp_ns_; |
| 472 | } |
| 473 | const std::deque<int64_t>& thread_duration_ns() const { |
| 474 | return thread_duration_ns_; |
| 475 | } |
| 476 | const std::deque<int64_t>& thread_instruction_counts() const { |
| 477 | return thread_instruction_counts_; |
| 478 | } |
| 479 | const std::deque<int64_t>& thread_instruction_deltas() const { |
| 480 | return thread_instruction_deltas_; |
| 481 | } |
| 482 | |
Mikhail Khokhlov | 7db0491 | 2019-07-18 16:11:11 +0100 | [diff] [blame] | 483 | base::Optional<uint32_t> FindRowForSliceId(uint32_t slice_id) const { |
Eric Seckler | d3b89d5 | 2019-07-10 15:36:29 +0100 | [diff] [blame] | 484 | auto it = |
| 485 | std::lower_bound(slice_ids().begin(), slice_ids().end(), slice_id); |
Mikhail Khokhlov | 7db0491 | 2019-07-18 16:11:11 +0100 | [diff] [blame] | 486 | if (it != slice_ids().end() && *it == slice_id) { |
| 487 | return static_cast<uint32_t>(std::distance(slice_ids().begin(), it)); |
| 488 | } |
| 489 | return base::nullopt; |
Eric Seckler | d3b89d5 | 2019-07-10 15:36:29 +0100 | [diff] [blame] | 490 | } |
| 491 | |
Eric Seckler | 54f30a3 | 2019-07-19 15:10:29 +0100 | [diff] [blame] | 492 | void UpdateThreadDeltasForSliceId(uint32_t slice_id, |
| 493 | int64_t end_thread_timestamp_ns, |
| 494 | int64_t end_thread_instruction_count) { |
Mikhail Khokhlov | 7db0491 | 2019-07-18 16:11:11 +0100 | [diff] [blame] | 495 | uint32_t row = *FindRowForSliceId(slice_id); |
Eric Seckler | d3b89d5 | 2019-07-10 15:36:29 +0100 | [diff] [blame] | 496 | int64_t begin_ns = thread_timestamp_ns_[row]; |
| 497 | thread_duration_ns_[row] = end_thread_timestamp_ns - begin_ns; |
Eric Seckler | 54f30a3 | 2019-07-19 15:10:29 +0100 | [diff] [blame] | 498 | int64_t begin_ticount = thread_instruction_counts_[row]; |
| 499 | thread_instruction_deltas_[row] = |
| 500 | end_thread_instruction_count - begin_ticount; |
Eric Seckler | d3b89d5 | 2019-07-10 15:36:29 +0100 | [diff] [blame] | 501 | } |
| 502 | |
| 503 | private: |
| 504 | std::deque<uint32_t> slice_ids_; |
| 505 | std::deque<int64_t> thread_timestamp_ns_; |
| 506 | std::deque<int64_t> thread_duration_ns_; |
| 507 | std::deque<int64_t> thread_instruction_counts_; |
| 508 | std::deque<int64_t> thread_instruction_deltas_; |
| 509 | }; |
| 510 | |
Lalit Maganti | 8320e6d | 2019-03-14 18:49:33 +0000 | [diff] [blame] | 511 | class CounterDefinitions { |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 512 | public: |
Lalit Maganti | 8320e6d | 2019-03-14 18:49:33 +0000 | [diff] [blame] | 513 | using Id = uint32_t; |
Lalit Maganti | 521d97b | 2019-04-29 13:47:03 +0100 | [diff] [blame] | 514 | static constexpr Id kInvalidId = std::numeric_limits<Id>::max(); |
Lalit Maganti | 8320e6d | 2019-03-14 18:49:33 +0000 | [diff] [blame] | 515 | |
| 516 | inline Id AddCounterDefinition(StringId name_id, |
| 517 | int64_t ref, |
Pascal Muetschard | 91d0789 | 2019-08-26 13:55:06 -0700 | [diff] [blame] | 518 | RefType type, |
Pascal Muetschard | ceb5c82 | 2019-08-26 14:39:15 -0700 | [diff] [blame] | 519 | StringId desc_id = 0, |
| 520 | StringId unit_id = 0) { |
Lalit Maganti | 8320e6d | 2019-03-14 18:49:33 +0000 | [diff] [blame] | 521 | base::Hash hash; |
| 522 | hash.Update(name_id); |
| 523 | hash.Update(ref); |
| 524 | hash.Update(type); |
| 525 | |
| 526 | // TODO(lalitm): this is a perf bottleneck and likely we can do something |
| 527 | // quite a bit better here. |
| 528 | uint64_t digest = hash.digest(); |
| 529 | auto it = hash_to_row_idx_.find(digest); |
| 530 | if (it != hash_to_row_idx_.end()) |
| 531 | return it->second; |
| 532 | |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 533 | name_ids_.emplace_back(name_id); |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 534 | refs_.emplace_back(ref); |
| 535 | types_.emplace_back(type); |
Pascal Muetschard | 91d0789 | 2019-08-26 13:55:06 -0700 | [diff] [blame] | 536 | desc_ids_.emplace_back(desc_id); |
Pascal Muetschard | ceb5c82 | 2019-08-26 14:39:15 -0700 | [diff] [blame] | 537 | unit_ids_.emplace_back(unit_id); |
Lalit Maganti | 8320e6d | 2019-03-14 18:49:33 +0000 | [diff] [blame] | 538 | hash_to_row_idx_.emplace(digest, size() - 1); |
| 539 | return size() - 1; |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 540 | } |
Lalit Maganti | fde2904 | 2018-10-04 13:28:52 +0100 | [diff] [blame] | 541 | |
Lalit Maganti | 8320e6d | 2019-03-14 18:49:33 +0000 | [diff] [blame] | 542 | uint32_t size() const { return static_cast<uint32_t>(name_ids_.size()); } |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 543 | |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 544 | const std::deque<StringId>& name_ids() const { return name_ids_; } |
| 545 | |
Pascal Muetschard | 91d0789 | 2019-08-26 13:55:06 -0700 | [diff] [blame] | 546 | const std::deque<StringId>& desc_ids() const { return desc_ids_; } |
| 547 | |
Pascal Muetschard | ceb5c82 | 2019-08-26 14:39:15 -0700 | [diff] [blame] | 548 | const std::deque<StringId>& unit_ids() const { return unit_ids_; } |
| 549 | |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 550 | const std::deque<int64_t>& refs() const { return refs_; } |
| 551 | |
| 552 | const std::deque<RefType>& types() const { return types_; } |
| 553 | |
Lalit Maganti | 8320e6d | 2019-03-14 18:49:33 +0000 | [diff] [blame] | 554 | private: |
| 555 | std::deque<StringId> name_ids_; |
| 556 | std::deque<int64_t> refs_; |
| 557 | std::deque<RefType> types_; |
Pascal Muetschard | 91d0789 | 2019-08-26 13:55:06 -0700 | [diff] [blame] | 558 | std::deque<StringId> desc_ids_; |
Pascal Muetschard | ceb5c82 | 2019-08-26 14:39:15 -0700 | [diff] [blame] | 559 | std::deque<StringId> unit_ids_; |
Lalit Maganti | 8320e6d | 2019-03-14 18:49:33 +0000 | [diff] [blame] | 560 | |
| 561 | std::unordered_map<uint64_t, uint32_t> hash_to_row_idx_; |
| 562 | }; |
| 563 | |
| 564 | class CounterValues { |
| 565 | public: |
| 566 | inline uint32_t AddCounterValue(CounterDefinitions::Id counter_id, |
| 567 | int64_t timestamp, |
| 568 | double value) { |
| 569 | counter_ids_.emplace_back(counter_id); |
| 570 | timestamps_.emplace_back(timestamp); |
| 571 | values_.emplace_back(value); |
| 572 | arg_set_ids_.emplace_back(kInvalidArgSetId); |
Ioannis Ilkos | f129c26 | 2019-04-25 14:53:51 +0100 | [diff] [blame] | 573 | |
Lalit Maganti | 521d97b | 2019-04-29 13:47:03 +0100 | [diff] [blame] | 574 | if (counter_id != CounterDefinitions::kInvalidId) { |
| 575 | if (counter_id >= rows_for_counter_id_.size()) { |
| 576 | rows_for_counter_id_.resize(counter_id + 1); |
| 577 | } |
| 578 | rows_for_counter_id_[counter_id].emplace_back(size() - 1); |
| 579 | } |
| 580 | return size() - 1; |
| 581 | } |
| 582 | |
| 583 | void set_counter_id(uint32_t index, CounterDefinitions::Id counter_id) { |
| 584 | PERFETTO_DCHECK(counter_ids_[index] == CounterDefinitions::kInvalidId); |
| 585 | |
| 586 | counter_ids_[index] = counter_id; |
Ioannis Ilkos | f129c26 | 2019-04-25 14:53:51 +0100 | [diff] [blame] | 587 | if (counter_id >= rows_for_counter_id_.size()) { |
| 588 | rows_for_counter_id_.resize(counter_id + 1); |
| 589 | } |
Lalit Maganti | 521d97b | 2019-04-29 13:47:03 +0100 | [diff] [blame] | 590 | |
| 591 | auto* new_rows = &rows_for_counter_id_[counter_id]; |
| 592 | new_rows->insert( |
| 593 | std::upper_bound(new_rows->begin(), new_rows->end(), index), index); |
Lalit Maganti | 8320e6d | 2019-03-14 18:49:33 +0000 | [diff] [blame] | 594 | } |
| 595 | |
| 596 | void set_arg_set_id(uint32_t row, ArgSetId id) { arg_set_ids_[row] = id; } |
| 597 | |
| 598 | uint32_t size() const { return static_cast<uint32_t>(counter_ids_.size()); } |
| 599 | |
| 600 | const std::deque<CounterDefinitions::Id>& counter_ids() const { |
| 601 | return counter_ids_; |
| 602 | } |
| 603 | |
| 604 | const std::deque<int64_t>& timestamps() const { return timestamps_; } |
| 605 | |
| 606 | const std::deque<double>& values() const { return values_; } |
| 607 | |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 608 | const std::deque<ArgSetId>& arg_set_ids() const { return arg_set_ids_; } |
| 609 | |
Ioannis Ilkos | f129c26 | 2019-04-25 14:53:51 +0100 | [diff] [blame] | 610 | const std::deque<std::vector<uint32_t>>& rows_for_counter_id() const { |
| 611 | return rows_for_counter_id_; |
| 612 | } |
| 613 | |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 614 | private: |
Lalit Maganti | 8320e6d | 2019-03-14 18:49:33 +0000 | [diff] [blame] | 615 | std::deque<CounterDefinitions::Id> counter_ids_; |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 616 | std::deque<int64_t> timestamps_; |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 617 | std::deque<double> values_; |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 618 | std::deque<ArgSetId> arg_set_ids_; |
Ioannis Ilkos | f129c26 | 2019-04-25 14:53:51 +0100 | [diff] [blame] | 619 | |
| 620 | // Indexed by counter_id value and contains the row numbers corresponding to |
| 621 | // it. |
| 622 | std::deque<std::vector<uint32_t>> rows_for_counter_id_; |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 623 | }; |
| 624 | |
Primiano Tucci | 5cb84f8 | 2018-10-31 21:46:36 -0700 | [diff] [blame] | 625 | class SqlStats { |
| 626 | public: |
| 627 | static constexpr size_t kMaxLogEntries = 100; |
Lalit Maganti | aac2f65 | 2019-04-30 12:16:21 +0100 | [diff] [blame] | 628 | uint32_t RecordQueryBegin(const std::string& query, |
| 629 | int64_t time_queued, |
| 630 | int64_t time_started); |
| 631 | void RecordQueryFirstNext(uint32_t row, int64_t time_first_next); |
| 632 | void RecordQueryEnd(uint32_t row, int64_t time_end); |
Primiano Tucci | 5cb84f8 | 2018-10-31 21:46:36 -0700 | [diff] [blame] | 633 | size_t size() const { return queries_.size(); } |
| 634 | const std::deque<std::string>& queries() const { return queries_; } |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 635 | const std::deque<int64_t>& times_queued() const { return times_queued_; } |
| 636 | const std::deque<int64_t>& times_started() const { return times_started_; } |
Lalit Maganti | aac2f65 | 2019-04-30 12:16:21 +0100 | [diff] [blame] | 637 | const std::deque<int64_t>& times_first_next() const { |
| 638 | return times_first_next_; |
| 639 | } |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 640 | const std::deque<int64_t>& times_ended() const { return times_ended_; } |
Primiano Tucci | 5cb84f8 | 2018-10-31 21:46:36 -0700 | [diff] [blame] | 641 | |
| 642 | private: |
Lalit Maganti | aac2f65 | 2019-04-30 12:16:21 +0100 | [diff] [blame] | 643 | uint32_t popped_queries_ = 0; |
| 644 | |
Primiano Tucci | 5cb84f8 | 2018-10-31 21:46:36 -0700 | [diff] [blame] | 645 | std::deque<std::string> queries_; |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 646 | std::deque<int64_t> times_queued_; |
| 647 | std::deque<int64_t> times_started_; |
Lalit Maganti | aac2f65 | 2019-04-30 12:16:21 +0100 | [diff] [blame] | 648 | std::deque<int64_t> times_first_next_; |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 649 | std::deque<int64_t> times_ended_; |
Primiano Tucci | 5cb84f8 | 2018-10-31 21:46:36 -0700 | [diff] [blame] | 650 | }; |
| 651 | |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 652 | class Instants { |
| 653 | public: |
Lalit Maganti | 66ed7ad | 2019-01-11 16:47:26 +0000 | [diff] [blame] | 654 | inline uint32_t AddInstantEvent(int64_t timestamp, |
| 655 | StringId name_id, |
| 656 | double value, |
| 657 | int64_t ref, |
| 658 | RefType type) { |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 659 | timestamps_.emplace_back(timestamp); |
| 660 | name_ids_.emplace_back(name_id); |
| 661 | values_.emplace_back(value); |
| 662 | refs_.emplace_back(ref); |
| 663 | types_.emplace_back(type); |
Lalit Maganti | 1c21d17 | 2019-02-07 10:48:24 +0000 | [diff] [blame] | 664 | arg_set_ids_.emplace_back(kInvalidArgSetId); |
Lalit Maganti | 66ed7ad | 2019-01-11 16:47:26 +0000 | [diff] [blame] | 665 | return static_cast<uint32_t>(instant_count() - 1); |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 666 | } |
| 667 | |
Lalit Maganti | 521d97b | 2019-04-29 13:47:03 +0100 | [diff] [blame] | 668 | void set_ref(uint32_t row, int64_t ref) { refs_[row] = ref; } |
| 669 | |
Lalit Maganti | 1c21d17 | 2019-02-07 10:48:24 +0000 | [diff] [blame] | 670 | void set_arg_set_id(uint32_t row, ArgSetId id) { arg_set_ids_[row] = id; } |
| 671 | |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 672 | size_t instant_count() const { return timestamps_.size(); } |
| 673 | |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 674 | const std::deque<int64_t>& timestamps() const { return timestamps_; } |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 675 | |
| 676 | const std::deque<StringId>& name_ids() const { return name_ids_; } |
| 677 | |
| 678 | const std::deque<double>& values() const { return values_; } |
| 679 | |
| 680 | const std::deque<int64_t>& refs() const { return refs_; } |
| 681 | |
| 682 | const std::deque<RefType>& types() const { return types_; } |
| 683 | |
Lalit Maganti | 1c21d17 | 2019-02-07 10:48:24 +0000 | [diff] [blame] | 684 | const std::deque<ArgSetId>& arg_set_ids() const { return arg_set_ids_; } |
| 685 | |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 686 | private: |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 687 | std::deque<int64_t> timestamps_; |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 688 | std::deque<StringId> name_ids_; |
| 689 | std::deque<double> values_; |
| 690 | std::deque<int64_t> refs_; |
| 691 | std::deque<RefType> types_; |
Lalit Maganti | 1c21d17 | 2019-02-07 10:48:24 +0000 | [diff] [blame] | 692 | std::deque<ArgSetId> arg_set_ids_; |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 693 | }; |
| 694 | |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 695 | class RawEvents { |
| 696 | public: |
| 697 | inline RowId AddRawEvent(int64_t timestamp, |
| 698 | StringId name_id, |
Lalit Maganti | e87cc81 | 2019-01-10 15:20:06 +0000 | [diff] [blame] | 699 | uint32_t cpu, |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 700 | UniqueTid utid) { |
| 701 | timestamps_.emplace_back(timestamp); |
| 702 | name_ids_.emplace_back(name_id); |
Lalit Maganti | e87cc81 | 2019-01-10 15:20:06 +0000 | [diff] [blame] | 703 | cpus_.emplace_back(cpu); |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 704 | utids_.emplace_back(utid); |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 705 | arg_set_ids_.emplace_back(kInvalidArgSetId); |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 706 | return CreateRowId(TableId::kRawEvents, |
| 707 | static_cast<uint32_t>(raw_event_count() - 1)); |
| 708 | } |
| 709 | |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 710 | void set_arg_set_id(uint32_t row, ArgSetId id) { arg_set_ids_[row] = id; } |
| 711 | |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 712 | size_t raw_event_count() const { return timestamps_.size(); } |
| 713 | |
| 714 | const std::deque<int64_t>& timestamps() const { return timestamps_; } |
| 715 | |
| 716 | const std::deque<StringId>& name_ids() const { return name_ids_; } |
| 717 | |
Lalit Maganti | e87cc81 | 2019-01-10 15:20:06 +0000 | [diff] [blame] | 718 | const std::deque<uint32_t>& cpus() const { return cpus_; } |
| 719 | |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 720 | const std::deque<UniqueTid>& utids() const { return utids_; } |
| 721 | |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 722 | const std::deque<ArgSetId>& arg_set_ids() const { return arg_set_ids_; } |
| 723 | |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 724 | private: |
| 725 | std::deque<int64_t> timestamps_; |
| 726 | std::deque<StringId> name_ids_; |
Lalit Maganti | e87cc81 | 2019-01-10 15:20:06 +0000 | [diff] [blame] | 727 | std::deque<uint32_t> cpus_; |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 728 | std::deque<UniqueTid> utids_; |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 729 | std::deque<ArgSetId> arg_set_ids_; |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 730 | }; |
| 731 | |
Primiano Tucci | 2c761ef | 2019-01-07 20:20:46 +0000 | [diff] [blame] | 732 | class AndroidLogs { |
| 733 | public: |
| 734 | inline size_t AddLogEvent(int64_t timestamp, |
| 735 | UniqueTid utid, |
| 736 | uint8_t prio, |
| 737 | StringId tag_id, |
| 738 | StringId msg_id) { |
| 739 | timestamps_.emplace_back(timestamp); |
| 740 | utids_.emplace_back(utid); |
| 741 | prios_.emplace_back(prio); |
| 742 | tag_ids_.emplace_back(tag_id); |
| 743 | msg_ids_.emplace_back(msg_id); |
| 744 | return size() - 1; |
| 745 | } |
| 746 | |
| 747 | size_t size() const { return timestamps_.size(); } |
| 748 | |
| 749 | const std::deque<int64_t>& timestamps() const { return timestamps_; } |
| 750 | const std::deque<UniqueTid>& utids() const { return utids_; } |
| 751 | const std::deque<uint8_t>& prios() const { return prios_; } |
| 752 | const std::deque<StringId>& tag_ids() const { return tag_ids_; } |
| 753 | const std::deque<StringId>& msg_ids() const { return msg_ids_; } |
| 754 | |
| 755 | private: |
| 756 | std::deque<int64_t> timestamps_; |
| 757 | std::deque<UniqueTid> utids_; |
| 758 | std::deque<uint8_t> prios_; |
| 759 | std::deque<StringId> tag_ids_; |
| 760 | std::deque<StringId> msg_ids_; |
| 761 | }; |
| 762 | |
Primiano Tucci | 0e38a14 | 2019-01-07 20:51:09 +0000 | [diff] [blame] | 763 | struct Stats { |
| 764 | using IndexMap = std::map<int, int64_t>; |
| 765 | int64_t value = 0; |
| 766 | IndexMap indexed_values; |
| 767 | }; |
| 768 | using StatsMap = std::array<Stats, stats::kNumKeys>; |
| 769 | |
Ryan Savitski | 51413ad | 2019-07-09 14:25:21 +0100 | [diff] [blame] | 770 | class Metadata { |
| 771 | public: |
| 772 | const std::deque<metadata::KeyIDs>& keys() const { return keys_; } |
| 773 | const std::deque<Variadic>& values() const { return values_; } |
| 774 | |
| 775 | RowId SetScalarMetadata(metadata::KeyIDs key, Variadic value) { |
| 776 | PERFETTO_DCHECK(key < metadata::kNumKeys); |
| 777 | PERFETTO_DCHECK(metadata::kKeyTypes[key] == metadata::kSingle); |
| 778 | PERFETTO_DCHECK(value.type == metadata::kValueTypes[key]); |
| 779 | |
| 780 | // Already set - on release builds, overwrite the previous value. |
| 781 | auto it = scalar_indices.find(key); |
| 782 | if (it != scalar_indices.end()) { |
| 783 | PERFETTO_DFATAL("Setting a scalar metadata entry more than once."); |
| 784 | uint32_t index = static_cast<uint32_t>(it->second); |
| 785 | values_[index] = value; |
| 786 | return TraceStorage::CreateRowId(kMetadataTable, index); |
| 787 | } |
| 788 | // First time setting this key. |
| 789 | keys_.push_back(key); |
| 790 | values_.push_back(value); |
| 791 | uint32_t index = static_cast<uint32_t>(keys_.size() - 1); |
| 792 | scalar_indices[key] = index; |
| 793 | return TraceStorage::CreateRowId(kMetadataTable, index); |
| 794 | } |
| 795 | |
| 796 | RowId AppendMetadata(metadata::KeyIDs key, Variadic value) { |
| 797 | PERFETTO_DCHECK(key < metadata::kNumKeys); |
| 798 | PERFETTO_DCHECK(metadata::kKeyTypes[key] == metadata::kMulti); |
| 799 | PERFETTO_DCHECK(value.type == metadata::kValueTypes[key]); |
| 800 | |
| 801 | keys_.push_back(key); |
| 802 | values_.push_back(value); |
| 803 | uint32_t index = static_cast<uint32_t>(keys_.size() - 1); |
| 804 | return TraceStorage::CreateRowId(kMetadataTable, index); |
| 805 | } |
| 806 | |
Ryan Savitski | 0476ee9 | 2019-07-09 14:29:33 +0100 | [diff] [blame] | 807 | void OverwriteMetadata(uint32_t index, Variadic value) { |
| 808 | PERFETTO_DCHECK(index < values_.size()); |
| 809 | values_[index] = value; |
| 810 | } |
| 811 | |
Ryan Savitski | 51413ad | 2019-07-09 14:25:21 +0100 | [diff] [blame] | 812 | private: |
| 813 | std::deque<metadata::KeyIDs> keys_; |
| 814 | std::deque<Variadic> values_; |
| 815 | // Extraneous state to track locations of entries that should have at most |
| 816 | // one row. Used only to maintain uniqueness during insertions. |
| 817 | std::map<metadata::KeyIDs, uint32_t> scalar_indices; |
| 818 | }; |
Mikhail Khokhlov | e466c00 | 2019-05-23 13:33:33 +0100 | [diff] [blame] | 819 | |
Oystein Eftevaag | 5419c58 | 2019-08-21 13:58:49 -0700 | [diff] [blame] | 820 | class StackProfileFrames { |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 821 | public: |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 822 | struct Row { |
| 823 | StringId name_id; |
| 824 | int64_t mapping_row; |
| 825 | int64_t rel_pc; |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 826 | |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 827 | bool operator==(const Row& other) const { |
| 828 | return std::tie(name_id, mapping_row, rel_pc) == |
| 829 | std::tie(other.name_id, other.mapping_row, other.rel_pc); |
| 830 | } |
| 831 | }; |
| 832 | |
Lalit Maganti | 9b2d52b | 2019-05-07 14:32:15 +0100 | [diff] [blame] | 833 | uint32_t size() const { return static_cast<uint32_t>(names_.size()); } |
| 834 | |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 835 | int64_t Insert(const Row& row) { |
| 836 | names_.emplace_back(row.name_id); |
| 837 | mappings_.emplace_back(row.mapping_row); |
| 838 | rel_pcs_.emplace_back(row.rel_pc); |
Ioannis Ilkos | e0b47f5 | 2019-09-18 11:14:57 +0100 | [diff] [blame] | 839 | symbol_set_ids_.emplace_back(0); |
Florian Mayer | a480cd6 | 2019-09-24 10:36:56 +0100 | [diff] [blame] | 840 | size_t row_number = names_.size() - 1; |
| 841 | index_.emplace(std::make_pair(row.mapping_row, row.rel_pc), row_number); |
| 842 | return static_cast<int64_t>(row_number); |
| 843 | } |
| 844 | |
| 845 | ssize_t FindFrameRow(size_t mapping_row, uint64_t rel_pc) const { |
| 846 | auto it = index_.find(std::make_pair(mapping_row, rel_pc)); |
| 847 | if (it == index_.end()) |
| 848 | return -1; |
| 849 | return static_cast<ssize_t>(it->second); |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 850 | } |
| 851 | |
Ioannis Ilkos | e0b47f5 | 2019-09-18 11:14:57 +0100 | [diff] [blame] | 852 | void SetSymbolSetId(size_t row_idx, uint32_t symbol_set_id) { |
| 853 | PERFETTO_CHECK(row_idx < symbol_set_ids_.size()); |
| 854 | symbol_set_ids_[row_idx] = symbol_set_id; |
Ioannis Ilkos | e672755 | 2019-08-14 15:10:59 +0100 | [diff] [blame] | 855 | } |
| 856 | |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 857 | const std::deque<StringId>& names() const { return names_; } |
| 858 | const std::deque<int64_t>& mappings() const { return mappings_; } |
| 859 | const std::deque<int64_t>& rel_pcs() const { return rel_pcs_; } |
Ioannis Ilkos | e0b47f5 | 2019-09-18 11:14:57 +0100 | [diff] [blame] | 860 | const std::deque<uint32_t>& symbol_set_ids() const { |
| 861 | return symbol_set_ids_; |
| 862 | } |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 863 | |
| 864 | private: |
| 865 | std::deque<StringId> names_; |
| 866 | std::deque<int64_t> mappings_; |
| 867 | std::deque<int64_t> rel_pcs_; |
Ioannis Ilkos | e0b47f5 | 2019-09-18 11:14:57 +0100 | [diff] [blame] | 868 | std::deque<uint32_t> symbol_set_ids_; |
Florian Mayer | a480cd6 | 2019-09-24 10:36:56 +0100 | [diff] [blame] | 869 | |
| 870 | std::map<std::pair<size_t /* mapping row */, uint64_t /* rel_pc */>, size_t> |
| 871 | index_; |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 872 | }; |
| 873 | |
Oystein Eftevaag | 5419c58 | 2019-08-21 13:58:49 -0700 | [diff] [blame] | 874 | class StackProfileCallsites { |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 875 | public: |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 876 | struct Row { |
| 877 | int64_t depth; |
| 878 | int64_t parent_id; |
| 879 | int64_t frame_row; |
| 880 | |
| 881 | bool operator==(const Row& other) const { |
| 882 | return std::tie(depth, parent_id, frame_row) == |
| 883 | std::tie(other.depth, other.parent_id, other.frame_row); |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 884 | } |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 885 | }; |
| 886 | |
Lalit Maganti | 9b2d52b | 2019-05-07 14:32:15 +0100 | [diff] [blame] | 887 | uint32_t size() const { return static_cast<uint32_t>(frame_ids_.size()); } |
| 888 | |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 889 | int64_t Insert(const Row& row) { |
| 890 | frame_depths_.emplace_back(row.depth); |
| 891 | parent_callsite_ids_.emplace_back(row.parent_id); |
| 892 | frame_ids_.emplace_back(row.frame_row); |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 893 | return static_cast<int64_t>(frame_depths_.size()) - 1; |
| 894 | } |
| 895 | |
| 896 | const std::deque<int64_t>& frame_depths() const { return frame_depths_; } |
| 897 | const std::deque<int64_t>& parent_callsite_ids() const { |
| 898 | return parent_callsite_ids_; |
| 899 | } |
| 900 | const std::deque<int64_t>& frame_ids() const { return frame_ids_; } |
| 901 | |
| 902 | private: |
| 903 | std::deque<int64_t> frame_depths_; |
| 904 | std::deque<int64_t> parent_callsite_ids_; |
| 905 | std::deque<int64_t> frame_ids_; |
| 906 | }; |
| 907 | |
Oystein Eftevaag | 5419c58 | 2019-08-21 13:58:49 -0700 | [diff] [blame] | 908 | class StackProfileMappings { |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 909 | public: |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 910 | struct Row { |
| 911 | StringId build_id; |
Florian Mayer | 1265573 | 2019-07-02 15:08:26 +0100 | [diff] [blame] | 912 | int64_t exact_offset; |
| 913 | int64_t start_offset; |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 914 | int64_t start; |
| 915 | int64_t end; |
| 916 | int64_t load_bias; |
| 917 | StringId name_id; |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 918 | |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 919 | bool operator==(const Row& other) const { |
Florian Mayer | 1265573 | 2019-07-02 15:08:26 +0100 | [diff] [blame] | 920 | return std::tie(build_id, exact_offset, start_offset, start, end, |
| 921 | load_bias, name_id) == |
| 922 | std::tie(other.build_id, other.exact_offset, other.start_offset, |
| 923 | other.start, other.end, other.load_bias, other.name_id); |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 924 | } |
| 925 | }; |
| 926 | |
Lalit Maganti | 9b2d52b | 2019-05-07 14:32:15 +0100 | [diff] [blame] | 927 | uint32_t size() const { return static_cast<uint32_t>(names_.size()); } |
| 928 | |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 929 | int64_t Insert(const Row& row) { |
| 930 | build_ids_.emplace_back(row.build_id); |
Florian Mayer | 1265573 | 2019-07-02 15:08:26 +0100 | [diff] [blame] | 931 | exact_offsets_.emplace_back(row.exact_offset); |
| 932 | start_offsets_.emplace_back(row.start_offset); |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 933 | starts_.emplace_back(row.start); |
| 934 | ends_.emplace_back(row.end); |
| 935 | load_biases_.emplace_back(row.load_bias); |
| 936 | names_.emplace_back(row.name_id); |
Florian Mayer | a480cd6 | 2019-09-24 10:36:56 +0100 | [diff] [blame] | 937 | |
| 938 | size_t row_number = build_ids_.size() - 1; |
| 939 | index_.emplace(std::make_pair(row.name_id, row.build_id), row_number); |
| 940 | return static_cast<int64_t>(row_number); |
| 941 | } |
| 942 | |
| 943 | ssize_t FindMappingRow(StringId name, StringId build_id) const { |
| 944 | auto it = index_.find(std::make_pair(name, build_id)); |
| 945 | if (it == index_.end()) |
| 946 | return -1; |
| 947 | return static_cast<ssize_t>(it->second); |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 948 | } |
| 949 | |
| 950 | const std::deque<StringId>& build_ids() const { return build_ids_; } |
Florian Mayer | 1265573 | 2019-07-02 15:08:26 +0100 | [diff] [blame] | 951 | const std::deque<int64_t>& exact_offsets() const { return exact_offsets_; } |
| 952 | const std::deque<int64_t>& start_offsets() const { return start_offsets_; } |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 953 | const std::deque<int64_t>& starts() const { return starts_; } |
| 954 | const std::deque<int64_t>& ends() const { return ends_; } |
| 955 | const std::deque<int64_t>& load_biases() const { return load_biases_; } |
| 956 | const std::deque<StringId>& names() const { return names_; } |
| 957 | |
| 958 | private: |
| 959 | std::deque<StringId> build_ids_; |
Florian Mayer | 1265573 | 2019-07-02 15:08:26 +0100 | [diff] [blame] | 960 | std::deque<int64_t> exact_offsets_; |
| 961 | std::deque<int64_t> start_offsets_; |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 962 | std::deque<int64_t> starts_; |
| 963 | std::deque<int64_t> ends_; |
| 964 | std::deque<int64_t> load_biases_; |
| 965 | std::deque<StringId> names_; |
Florian Mayer | a480cd6 | 2019-09-24 10:36:56 +0100 | [diff] [blame] | 966 | |
| 967 | std::map<std::pair<StringId /* name */, StringId /* build id */>, size_t> |
| 968 | index_; |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 969 | }; |
| 970 | |
| 971 | class HeapProfileAllocations { |
| 972 | public: |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 973 | struct Row { |
| 974 | int64_t timestamp; |
Florian Mayer | df1968c | 2019-05-13 16:39:35 +0100 | [diff] [blame] | 975 | UniquePid upid; |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 976 | int64_t callsite_id; |
| 977 | int64_t count; |
| 978 | int64_t size; |
| 979 | }; |
| 980 | |
Lalit Maganti | 9b2d52b | 2019-05-07 14:32:15 +0100 | [diff] [blame] | 981 | uint32_t size() const { return static_cast<uint32_t>(timestamps_.size()); } |
| 982 | |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 983 | void Insert(const Row& row) { |
| 984 | timestamps_.emplace_back(row.timestamp); |
Florian Mayer | df1968c | 2019-05-13 16:39:35 +0100 | [diff] [blame] | 985 | upids_.emplace_back(row.upid); |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 986 | callsite_ids_.emplace_back(row.callsite_id); |
| 987 | counts_.emplace_back(row.count); |
| 988 | sizes_.emplace_back(row.size); |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 989 | } |
| 990 | |
| 991 | const std::deque<int64_t>& timestamps() const { return timestamps_; } |
Florian Mayer | df1968c | 2019-05-13 16:39:35 +0100 | [diff] [blame] | 992 | const std::deque<UniquePid>& upids() const { return upids_; } |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 993 | const std::deque<int64_t>& callsite_ids() const { return callsite_ids_; } |
| 994 | const std::deque<int64_t>& counts() const { return counts_; } |
| 995 | const std::deque<int64_t>& sizes() const { return sizes_; } |
| 996 | |
| 997 | private: |
| 998 | std::deque<int64_t> timestamps_; |
Florian Mayer | df1968c | 2019-05-13 16:39:35 +0100 | [diff] [blame] | 999 | std::deque<UniquePid> upids_; |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 1000 | std::deque<int64_t> callsite_ids_; |
| 1001 | std::deque<int64_t> counts_; |
| 1002 | std::deque<int64_t> sizes_; |
| 1003 | }; |
| 1004 | |
Oystein Eftevaag | 7f64c10 | 2019-08-29 10:27:31 -0700 | [diff] [blame] | 1005 | class CpuProfileStackSamples { |
| 1006 | public: |
| 1007 | struct Row { |
| 1008 | int64_t timestamp; |
| 1009 | int64_t callsite_id; |
| 1010 | UniqueTid utid; |
| 1011 | }; |
| 1012 | |
| 1013 | uint32_t size() const { return static_cast<uint32_t>(timestamps_.size()); } |
| 1014 | |
| 1015 | void Insert(const Row& row) { |
| 1016 | timestamps_.emplace_back(row.timestamp); |
| 1017 | callsite_ids_.emplace_back(row.callsite_id); |
| 1018 | utids_.emplace_back(row.utid); |
| 1019 | } |
| 1020 | |
| 1021 | const std::deque<int64_t>& timestamps() const { return timestamps_; } |
| 1022 | const std::deque<int64_t>& callsite_ids() const { return callsite_ids_; } |
| 1023 | const std::deque<UniqueTid>& utids() const { return utids_; } |
| 1024 | |
| 1025 | private: |
| 1026 | std::deque<int64_t> timestamps_; |
| 1027 | std::deque<int64_t> callsite_ids_; |
| 1028 | std::deque<UniqueTid> utids_; |
| 1029 | }; |
| 1030 | |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 1031 | UniqueTid AddEmptyThread(uint32_t tid) { |
| 1032 | unique_threads_.emplace_back(tid); |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 1033 | return static_cast<UniqueTid>(unique_threads_.size() - 1); |
| 1034 | } |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 1035 | |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 1036 | UniquePid AddEmptyProcess(uint32_t pid) { |
| 1037 | unique_processes_.emplace_back(pid); |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 1038 | return static_cast<UniquePid>(unique_processes_.size() - 1); |
| 1039 | } |
Isabelle Taylor | 3dd366c | 2018-06-22 16:21:41 +0100 | [diff] [blame] | 1040 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 1041 | // Return an unqiue identifier for the contents of each string. |
| 1042 | // The string is copied internally and can be destroyed after this called. |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 1043 | // Virtual for testing. |
Lalit Maganti | 5c45431 | 2019-04-08 12:11:17 +0100 | [diff] [blame] | 1044 | virtual StringId InternString(base::StringView str) { |
| 1045 | return string_pool_.InternString(str); |
| 1046 | } |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 1047 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 1048 | Process* GetMutableProcess(UniquePid upid) { |
Lalit Maganti | 676658b | 2018-11-20 18:24:31 +0000 | [diff] [blame] | 1049 | PERFETTO_DCHECK(upid < unique_processes_.size()); |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 1050 | return &unique_processes_[upid]; |
| 1051 | } |
Isabelle Taylor | 3dd366c | 2018-06-22 16:21:41 +0100 | [diff] [blame] | 1052 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 1053 | Thread* GetMutableThread(UniqueTid utid) { |
Florian Mayer | a1aaec2 | 2018-09-19 17:02:26 +0100 | [diff] [blame] | 1054 | PERFETTO_DCHECK(utid < unique_threads_.size()); |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 1055 | return &unique_threads_[utid]; |
| 1056 | } |
Isabelle Taylor | 3dd366c | 2018-06-22 16:21:41 +0100 | [diff] [blame] | 1057 | |
Primiano Tucci | 0e38a14 | 2019-01-07 20:51:09 +0000 | [diff] [blame] | 1058 | // Example usage: SetStats(stats::android_log_num_failed, 42); |
| 1059 | void SetStats(size_t key, int64_t value) { |
| 1060 | PERFETTO_DCHECK(key < stats::kNumKeys); |
| 1061 | PERFETTO_DCHECK(stats::kTypes[key] == stats::kSingle); |
| 1062 | stats_[key].value = value; |
| 1063 | } |
| 1064 | |
| 1065 | // Example usage: IncrementStats(stats::android_log_num_failed, -1); |
| 1066 | void IncrementStats(size_t key, int64_t increment = 1) { |
| 1067 | PERFETTO_DCHECK(key < stats::kNumKeys); |
| 1068 | PERFETTO_DCHECK(stats::kTypes[key] == stats::kSingle); |
| 1069 | stats_[key].value += increment; |
| 1070 | } |
| 1071 | |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 1072 | // Example usage: IncrementIndexedStats(stats::cpu_failure, 1); |
| 1073 | void IncrementIndexedStats(size_t key, int index, int64_t increment = 1) { |
| 1074 | PERFETTO_DCHECK(key < stats::kNumKeys); |
| 1075 | PERFETTO_DCHECK(stats::kTypes[key] == stats::kIndexed); |
| 1076 | stats_[key].indexed_values[index] += increment; |
| 1077 | } |
| 1078 | |
Primiano Tucci | 0e38a14 | 2019-01-07 20:51:09 +0000 | [diff] [blame] | 1079 | // Example usage: SetIndexedStats(stats::cpu_failure, 1, 42); |
| 1080 | void SetIndexedStats(size_t key, int index, int64_t value) { |
| 1081 | PERFETTO_DCHECK(key < stats::kNumKeys); |
| 1082 | PERFETTO_DCHECK(stats::kTypes[key] == stats::kIndexed); |
| 1083 | stats_[key].indexed_values[index] = value; |
| 1084 | } |
| 1085 | |
Mikhail Khokhlov | e466c00 | 2019-05-23 13:33:33 +0100 | [diff] [blame] | 1086 | // Example usage: |
| 1087 | // SetMetadata(metadata::benchmark_name, |
| 1088 | // Variadic::String(storage->InternString("foo")); |
Ryan Savitski | 51413ad | 2019-07-09 14:25:21 +0100 | [diff] [blame] | 1089 | // Returns the RowId of the new entry. |
Mikhail Khokhlov | b1fe42a | 2019-05-23 13:58:05 +0100 | [diff] [blame] | 1090 | // Virtual for testing. |
Ryan Savitski | 51413ad | 2019-07-09 14:25:21 +0100 | [diff] [blame] | 1091 | virtual RowId SetMetadata(metadata::KeyIDs key, Variadic value) { |
| 1092 | return metadata_.SetScalarMetadata(key, value); |
Mikhail Khokhlov | e466c00 | 2019-05-23 13:33:33 +0100 | [diff] [blame] | 1093 | } |
| 1094 | |
| 1095 | // Example usage: |
| 1096 | // AppendMetadata(metadata::benchmark_story_tags, |
| 1097 | // Variadic::String(storage->InternString("bar")); |
Ryan Savitski | 51413ad | 2019-07-09 14:25:21 +0100 | [diff] [blame] | 1098 | // Returns the RowId of the new entry. |
Mikhail Khokhlov | b1fe42a | 2019-05-23 13:58:05 +0100 | [diff] [blame] | 1099 | // Virtual for testing. |
Ryan Savitski | 51413ad | 2019-07-09 14:25:21 +0100 | [diff] [blame] | 1100 | virtual RowId AppendMetadata(metadata::KeyIDs key, Variadic value) { |
| 1101 | return metadata_.AppendMetadata(key, value); |
Mikhail Khokhlov | e466c00 | 2019-05-23 13:33:33 +0100 | [diff] [blame] | 1102 | } |
| 1103 | |
Eric Seckler | 77b5278 | 2019-05-02 15:18:57 +0100 | [diff] [blame] | 1104 | class ScopedStatsTracer { |
| 1105 | public: |
| 1106 | ScopedStatsTracer(TraceStorage* storage, size_t key) |
| 1107 | : storage_(storage), key_(key), start_ns_(base::GetWallTimeNs()) {} |
| 1108 | |
| 1109 | ~ScopedStatsTracer() { |
| 1110 | if (!storage_) |
| 1111 | return; |
| 1112 | auto delta_ns = base::GetWallTimeNs() - start_ns_; |
| 1113 | storage_->IncrementStats(key_, delta_ns.count()); |
| 1114 | } |
| 1115 | |
| 1116 | ScopedStatsTracer(ScopedStatsTracer&& other) noexcept { MoveImpl(&other); } |
| 1117 | |
| 1118 | ScopedStatsTracer& operator=(ScopedStatsTracer&& other) { |
| 1119 | MoveImpl(&other); |
| 1120 | return *this; |
| 1121 | } |
| 1122 | |
| 1123 | private: |
| 1124 | ScopedStatsTracer(const ScopedStatsTracer&) = delete; |
| 1125 | ScopedStatsTracer& operator=(const ScopedStatsTracer&) = delete; |
| 1126 | |
| 1127 | void MoveImpl(ScopedStatsTracer* other) { |
| 1128 | storage_ = other->storage_; |
| 1129 | key_ = other->key_; |
| 1130 | start_ns_ = other->start_ns_; |
| 1131 | other->storage_ = nullptr; |
| 1132 | } |
| 1133 | |
| 1134 | TraceStorage* storage_; |
| 1135 | size_t key_; |
| 1136 | base::TimeNanos start_ns_; |
| 1137 | }; |
| 1138 | |
| 1139 | ScopedStatsTracer TraceExecutionTimeIntoStats(size_t key) { |
| 1140 | return ScopedStatsTracer(this, key); |
| 1141 | } |
| 1142 | |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 1143 | // Reading methods. |
Eric Seckler | c93823e | 2019-06-03 16:49:19 +0100 | [diff] [blame] | 1144 | // Virtual for testing. |
| 1145 | virtual NullTermStringView GetString(StringId id) const { |
Lalit Maganti | 5c45431 | 2019-04-08 12:11:17 +0100 | [diff] [blame] | 1146 | return string_pool_.Get(id); |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 1147 | } |
| 1148 | |
Lalit Maganti | e9d4053 | 2018-06-29 13:15:06 +0100 | [diff] [blame] | 1149 | const Process& GetProcess(UniquePid upid) const { |
Lalit Maganti | 676658b | 2018-11-20 18:24:31 +0000 | [diff] [blame] | 1150 | PERFETTO_DCHECK(upid < unique_processes_.size()); |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 1151 | return unique_processes_[upid]; |
| 1152 | } |
| 1153 | |
Eric Seckler | b32cacf | 2019-09-27 16:51:19 +0100 | [diff] [blame] | 1154 | // Virtual for testing. |
| 1155 | virtual const Thread& GetThread(UniqueTid utid) const { |
Lalit Maganti | 1f64cfa | 2018-09-18 13:20:02 +0100 | [diff] [blame] | 1156 | // Allow utid == 0 for idle thread retrieval. |
Florian Mayer | a1aaec2 | 2018-09-19 17:02:26 +0100 | [diff] [blame] | 1157 | PERFETTO_DCHECK(utid < unique_threads_.size()); |
Isabelle Taylor | 68e4219 | 2018-06-19 16:19:31 +0100 | [diff] [blame] | 1158 | return unique_threads_[utid]; |
| 1159 | } |
| 1160 | |
Lalit Maganti | 5ea9e93 | 2018-11-30 14:19:39 +0000 | [diff] [blame] | 1161 | static RowId CreateRowId(TableId table, uint32_t row) { |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 1162 | return (static_cast<RowId>(table) << kRowIdTableShift) | row; |
Lalit Maganti | 5ea9e93 | 2018-11-30 14:19:39 +0000 | [diff] [blame] | 1163 | } |
| 1164 | |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 1165 | static std::pair<int8_t /*table*/, uint32_t /*row*/> ParseRowId(RowId rowid) { |
| 1166 | auto id = static_cast<uint64_t>(rowid); |
| 1167 | auto table_id = static_cast<uint8_t>(id >> kRowIdTableShift); |
| 1168 | auto row = static_cast<uint32_t>(id & ((1ull << kRowIdTableShift) - 1)); |
| 1169 | return std::make_pair(table_id, row); |
| 1170 | } |
| 1171 | |
Lalit Maganti | ac68e9c | 2019-09-09 18:12:15 +0100 | [diff] [blame] | 1172 | const tables::TrackTable& track_table() const { return track_table_; } |
| 1173 | tables::TrackTable* mutable_track_table() { return &track_table_; } |
Lalit Maganti | d11d3e0 | 2019-07-26 12:32:09 +0530 | [diff] [blame] | 1174 | |
Lalit Maganti | 53bdbb2 | 2019-09-25 11:11:18 +0100 | [diff] [blame] | 1175 | const tables::ProcessTrackTable& process_track_table() const { |
| 1176 | return process_track_table_; |
Lalit Maganti | 4ea78d9 | 2019-09-20 20:20:41 +0100 | [diff] [blame] | 1177 | } |
Lalit Maganti | 53bdbb2 | 2019-09-25 11:11:18 +0100 | [diff] [blame] | 1178 | tables::ProcessTrackTable* mutable_process_track_table() { |
| 1179 | return &process_track_table_; |
Lalit Maganti | 4ea78d9 | 2019-09-20 20:20:41 +0100 | [diff] [blame] | 1180 | } |
Eric Seckler | 5703ede | 2019-07-10 10:13:02 +0100 | [diff] [blame] | 1181 | |
Lalit Maganti | fedc15b | 2019-09-26 18:37:52 +0100 | [diff] [blame] | 1182 | const tables::ThreadTrackTable& thread_track_table() const { |
| 1183 | return thread_track_table_; |
| 1184 | } |
| 1185 | tables::ThreadTrackTable* mutable_thread_track_table() { |
| 1186 | return &thread_track_table_; |
| 1187 | } |
| 1188 | |
Lalit Maganti | ff69c11 | 2018-09-24 12:07:47 +0100 | [diff] [blame] | 1189 | const Slices& slices() const { return slices_; } |
Lalit Maganti | fde2904 | 2018-10-04 13:28:52 +0100 | [diff] [blame] | 1190 | Slices* mutable_slices() { return &slices_; } |
| 1191 | |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 1192 | const NestableSlices& nestable_slices() const { return nestable_slices_; } |
| 1193 | NestableSlices* mutable_nestable_slices() { return &nestable_slices_; } |
| 1194 | |
Eric Seckler | d3b89d5 | 2019-07-10 15:36:29 +0100 | [diff] [blame] | 1195 | const ThreadSlices& thread_slices() const { return thread_slices_; } |
| 1196 | ThreadSlices* mutable_thread_slices() { return &thread_slices_; } |
| 1197 | |
Eric Seckler | c3430c6 | 2019-07-22 10:49:58 +0100 | [diff] [blame] | 1198 | const VirtualTrackSlices& virtual_track_slices() const { |
| 1199 | return virtual_track_slices_; |
| 1200 | } |
| 1201 | VirtualTrackSlices* mutable_virtual_track_slices() { |
| 1202 | return &virtual_track_slices_; |
| 1203 | } |
| 1204 | |
Lalit Maganti | 20539c2 | 2019-09-04 12:36:10 +0100 | [diff] [blame] | 1205 | const tables::GpuSliceTable& gpu_slice_table() const { |
| 1206 | return gpu_slice_table_; |
| 1207 | } |
| 1208 | tables::GpuSliceTable* mutable_gpu_slice_table() { return &gpu_slice_table_; } |
Mikael Pessa | 7160ccc | 2019-07-25 11:19:26 -0700 | [diff] [blame] | 1209 | |
Lalit Maganti | 8320e6d | 2019-03-14 18:49:33 +0000 | [diff] [blame] | 1210 | const CounterDefinitions& counter_definitions() const { |
| 1211 | return counter_definitions_; |
| 1212 | } |
| 1213 | CounterDefinitions* mutable_counter_definitions() { |
| 1214 | return &counter_definitions_; |
| 1215 | } |
| 1216 | |
| 1217 | const CounterValues& counter_values() const { return counter_values_; } |
| 1218 | CounterValues* mutable_counter_values() { return &counter_values_; } |
Isabelle Taylor | 14674d4 | 2018-09-07 11:33:11 +0100 | [diff] [blame] | 1219 | |
Primiano Tucci | 5cb84f8 | 2018-10-31 21:46:36 -0700 | [diff] [blame] | 1220 | const SqlStats& sql_stats() const { return sql_stats_; } |
| 1221 | SqlStats* mutable_sql_stats() { return &sql_stats_; } |
| 1222 | |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 1223 | const Instants& instants() const { return instants_; } |
| 1224 | Instants* mutable_instants() { return &instants_; } |
| 1225 | |
Primiano Tucci | 2c761ef | 2019-01-07 20:20:46 +0000 | [diff] [blame] | 1226 | const AndroidLogs& android_logs() const { return android_log_; } |
| 1227 | AndroidLogs* mutable_android_log() { return &android_log_; } |
| 1228 | |
Primiano Tucci | 0e38a14 | 2019-01-07 20:51:09 +0000 | [diff] [blame] | 1229 | const StatsMap& stats() const { return stats_; } |
Lalit Maganti | 05e8c13 | 2018-11-09 18:16:12 +0000 | [diff] [blame] | 1230 | |
Ryan Savitski | 51413ad | 2019-07-09 14:25:21 +0100 | [diff] [blame] | 1231 | const Metadata& metadata() const { return metadata_; } |
Ryan Savitski | 0476ee9 | 2019-07-09 14:29:33 +0100 | [diff] [blame] | 1232 | Metadata* mutable_metadata() { return &metadata_; } |
Mikhail Khokhlov | e466c00 | 2019-05-23 13:33:33 +0100 | [diff] [blame] | 1233 | |
Lalit Maganti | 6e9c55e | 2018-11-29 12:00:39 +0000 | [diff] [blame] | 1234 | const Args& args() const { return args_; } |
| 1235 | Args* mutable_args() { return &args_; } |
| 1236 | |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 1237 | const RawEvents& raw_events() const { return raw_events_; } |
| 1238 | RawEvents* mutable_raw_events() { return &raw_events_; } |
| 1239 | |
Oystein Eftevaag | 5419c58 | 2019-08-21 13:58:49 -0700 | [diff] [blame] | 1240 | const StackProfileMappings& stack_profile_mappings() const { |
| 1241 | return stack_profile_mappings_; |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 1242 | } |
Oystein Eftevaag | 5419c58 | 2019-08-21 13:58:49 -0700 | [diff] [blame] | 1243 | StackProfileMappings* mutable_stack_profile_mappings() { |
| 1244 | return &stack_profile_mappings_; |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 1245 | } |
| 1246 | |
Oystein Eftevaag | 5419c58 | 2019-08-21 13:58:49 -0700 | [diff] [blame] | 1247 | const StackProfileFrames& stack_profile_frames() const { |
| 1248 | return stack_profile_frames_; |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 1249 | } |
Oystein Eftevaag | 5419c58 | 2019-08-21 13:58:49 -0700 | [diff] [blame] | 1250 | StackProfileFrames* mutable_stack_profile_frames() { |
| 1251 | return &stack_profile_frames_; |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 1252 | } |
| 1253 | |
Oystein Eftevaag | 5419c58 | 2019-08-21 13:58:49 -0700 | [diff] [blame] | 1254 | const StackProfileCallsites& stack_profile_callsites() const { |
| 1255 | return stack_profile_callsites_; |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 1256 | } |
Oystein Eftevaag | 5419c58 | 2019-08-21 13:58:49 -0700 | [diff] [blame] | 1257 | StackProfileCallsites* mutable_stack_profile_callsites() { |
| 1258 | return &stack_profile_callsites_; |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 1259 | } |
| 1260 | |
| 1261 | const HeapProfileAllocations& heap_profile_allocations() const { |
| 1262 | return heap_profile_allocations_; |
| 1263 | } |
| 1264 | HeapProfileAllocations* mutable_heap_profile_allocations() { |
| 1265 | return &heap_profile_allocations_; |
| 1266 | } |
Oystein Eftevaag | 7f64c10 | 2019-08-29 10:27:31 -0700 | [diff] [blame] | 1267 | const CpuProfileStackSamples& cpu_profile_stack_samples() const { |
| 1268 | return cpu_profile_stack_samples_; |
| 1269 | } |
| 1270 | CpuProfileStackSamples* mutable_cpu_profile_stack_samples() { |
| 1271 | return &cpu_profile_stack_samples_; |
| 1272 | } |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 1273 | |
Ioannis Ilkos | e0b47f5 | 2019-09-18 11:14:57 +0100 | [diff] [blame] | 1274 | const tables::SymbolTable& symbol_table() const { return symbol_table_; } |
| 1275 | |
| 1276 | tables::SymbolTable* mutable_symbol_table() { return &symbol_table_; } |
| 1277 | |
Florian Mayer | 25e013e | 2019-10-01 14:06:15 +0100 | [diff] [blame^] | 1278 | const tables::HeapGraphObjectTable& heap_graph_object_table() const { |
| 1279 | return heap_graph_object_table_; |
| 1280 | } |
| 1281 | |
| 1282 | tables::HeapGraphObjectTable* mutable_heap_graph_object_table() { |
| 1283 | return &heap_graph_object_table_; |
| 1284 | } |
| 1285 | |
Lalit Maganti | 20539c2 | 2019-09-04 12:36:10 +0100 | [diff] [blame] | 1286 | const tables::GpuTrackTable& gpu_track_table() const { |
| 1287 | return gpu_track_table_; |
| 1288 | } |
| 1289 | tables::GpuTrackTable* mutable_gpu_track_table() { return &gpu_track_table_; } |
Mikael Pessa | 7160ccc | 2019-07-25 11:19:26 -0700 | [diff] [blame] | 1290 | |
Lalit Maganti | 5c45431 | 2019-04-08 12:11:17 +0100 | [diff] [blame] | 1291 | const StringPool& string_pool() const { return string_pool_; } |
Lalit Maganti | acda68b | 2018-10-29 15:23:25 +0000 | [diff] [blame] | 1292 | |
Hector Dearman | 5145e50 | 2019-09-18 16:52:24 +0100 | [diff] [blame] | 1293 | // |unique_processes_| always contains at least 1 element because the 0th ID |
Isabelle Taylor | e7003fb | 2018-07-17 11:39:01 +0100 | [diff] [blame] | 1294 | // is reserved to indicate an invalid process. |
Lalit Maganti | 9c6395b | 2019-01-17 00:25:09 +0000 | [diff] [blame] | 1295 | size_t process_count() const { return unique_processes_.size(); } |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 1296 | |
Hector Dearman | 5145e50 | 2019-09-18 16:52:24 +0100 | [diff] [blame] | 1297 | // |unique_threads_| always contains at least 1 element because the 0th ID |
Isabelle Taylor | e7003fb | 2018-07-17 11:39:01 +0100 | [diff] [blame] | 1298 | // is reserved to indicate an invalid thread. |
Lalit Maganti | 9c6395b | 2019-01-17 00:25:09 +0000 | [diff] [blame] | 1299 | size_t thread_count() const { return unique_threads_.size(); } |
Isabelle Taylor | e7003fb | 2018-07-17 11:39:01 +0100 | [diff] [blame] | 1300 | |
Hector Dearman | 1232336 | 2018-08-09 16:09:28 +0100 | [diff] [blame] | 1301 | // Number of interned strings in the pool. Includes the empty string w/ ID=0. |
| 1302 | size_t string_count() const { return string_pool_.size(); } |
| 1303 | |
Ioannis Ilkos | b8b1110 | 2019-01-29 17:56:55 +0000 | [diff] [blame] | 1304 | // Start / end ts (in nanoseconds) across the parsed trace events. |
| 1305 | // Returns (0, 0) if the trace is empty. |
| 1306 | std::pair<int64_t, int64_t> GetTraceTimestampBoundsNs() const; |
| 1307 | |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 1308 | private: |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 1309 | static constexpr uint8_t kRowIdTableShift = 32; |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 1310 | |
Primiano Tucci | 2da5d2e | 2018-08-10 14:23:31 +0100 | [diff] [blame] | 1311 | using StringHash = uint64_t; |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 1312 | |
Lalit Maganti | 5c45431 | 2019-04-08 12:11:17 +0100 | [diff] [blame] | 1313 | TraceStorage(const TraceStorage&) = delete; |
| 1314 | TraceStorage& operator=(const TraceStorage&) = delete; |
| 1315 | |
Lalit Maganti | 20539c2 | 2019-09-04 12:36:10 +0100 | [diff] [blame] | 1316 | TraceStorage(TraceStorage&&) = delete; |
| 1317 | TraceStorage& operator=(TraceStorage&&) = delete; |
| 1318 | |
| 1319 | // One entry for each unique string in the trace. |
| 1320 | StringPool string_pool_; |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 1321 | |
Lalit Maganti | 05e8c13 | 2018-11-09 18:16:12 +0000 | [diff] [blame] | 1322 | // Stats about parsing the trace. |
Primiano Tucci | 0e38a14 | 2019-01-07 20:51:09 +0000 | [diff] [blame] | 1323 | StatsMap stats_{}; |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 1324 | |
Ryan Savitski | 51413ad | 2019-07-09 14:25:21 +0100 | [diff] [blame] | 1325 | // Extra data extracted from the trace. Includes: |
| 1326 | // * metadata from chrome and benchmarking infrastructure |
| 1327 | // * descriptions of android packages |
| 1328 | Metadata metadata_{}; |
Mikhail Khokhlov | e466c00 | 2019-05-23 13:33:33 +0100 | [diff] [blame] | 1329 | |
Lalit Maganti | d11d3e0 | 2019-07-26 12:32:09 +0530 | [diff] [blame] | 1330 | // Metadata for tracks. |
Lalit Maganti | ac68e9c | 2019-09-09 18:12:15 +0100 | [diff] [blame] | 1331 | tables::TrackTable track_table_{&string_pool_, nullptr}; |
Lalit Maganti | 4ea78d9 | 2019-09-20 20:20:41 +0100 | [diff] [blame] | 1332 | tables::GpuTrackTable gpu_track_table_{&string_pool_, &track_table_}; |
Lalit Maganti | 53bdbb2 | 2019-09-25 11:11:18 +0100 | [diff] [blame] | 1333 | tables::ProcessTrackTable process_track_table_{&string_pool_, &track_table_}; |
Lalit Maganti | fedc15b | 2019-09-26 18:37:52 +0100 | [diff] [blame] | 1334 | tables::ThreadTrackTable thread_track_table_{&string_pool_, &track_table_}; |
Eric Seckler | 5703ede | 2019-07-10 10:13:02 +0100 | [diff] [blame] | 1335 | |
Mikael Pessa | 803090c | 2019-08-23 16:03:34 -0700 | [diff] [blame] | 1336 | // Metadata for gpu tracks. |
Mikael Pessa | 803090c | 2019-08-23 16:03:34 -0700 | [diff] [blame] | 1337 | GpuContexts gpu_contexts_; |
| 1338 | |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 1339 | // One entry for each CPU in the trace. |
Lalit Maganti | ff69c11 | 2018-09-24 12:07:47 +0100 | [diff] [blame] | 1340 | Slices slices_; |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 1341 | |
Lalit Maganti | 6e9c55e | 2018-11-29 12:00:39 +0000 | [diff] [blame] | 1342 | // Args for all other tables. |
| 1343 | Args args_; |
| 1344 | |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 1345 | // One entry for each UniquePid, with UniquePid as the index. |
Ioannis Ilkos | 9c03cbd | 2019-03-12 18:30:43 +0000 | [diff] [blame] | 1346 | // Never hold on to pointers to Process, as vector resize will |
| 1347 | // invalidate them. |
| 1348 | std::vector<Process> unique_processes_; |
Isabelle Taylor | 68e4219 | 2018-06-19 16:19:31 +0100 | [diff] [blame] | 1349 | |
Isabelle Taylor | 68e4219 | 2018-06-19 16:19:31 +0100 | [diff] [blame] | 1350 | // One entry for each UniqueTid, with UniqueTid as the index. |
Isabelle Taylor | 3dd366c | 2018-06-22 16:21:41 +0100 | [diff] [blame] | 1351 | std::deque<Thread> unique_threads_; |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 1352 | |
| 1353 | // Slices coming from userspace events (e.g. Chromium TRACE_EVENT macros). |
| 1354 | NestableSlices nestable_slices_; |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 1355 | |
Eric Seckler | d3b89d5 | 2019-07-10 15:36:29 +0100 | [diff] [blame] | 1356 | // Additional attributes for threads slices (sub-type of NestableSlices). |
| 1357 | ThreadSlices thread_slices_; |
| 1358 | |
Eric Seckler | c3430c6 | 2019-07-22 10:49:58 +0100 | [diff] [blame] | 1359 | // Additional attributes for virtual track slices (sub-type of |
| 1360 | // NestableSlices). |
| 1361 | VirtualTrackSlices virtual_track_slices_; |
| 1362 | |
Mikael Pessa | 803090c | 2019-08-23 16:03:34 -0700 | [diff] [blame] | 1363 | // Additional attributes for gpu track slices (sub-type of |
| 1364 | // NestableSlices). |
Lalit Maganti | 20539c2 | 2019-09-04 12:36:10 +0100 | [diff] [blame] | 1365 | tables::GpuSliceTable gpu_slice_table_{&string_pool_, nullptr}; |
Mikael Pessa | 803090c | 2019-08-23 16:03:34 -0700 | [diff] [blame] | 1366 | |
Hector Dearman | 2442d61 | 2019-06-04 18:05:23 +0100 | [diff] [blame] | 1367 | // The type of counters in the trace. Can be thought of as the "metadata". |
Lalit Maganti | 8320e6d | 2019-03-14 18:49:33 +0000 | [diff] [blame] | 1368 | CounterDefinitions counter_definitions_; |
| 1369 | |
| 1370 | // The values from the Counter events from the trace. This includes CPU |
| 1371 | // frequency events as well systrace trace_marker counter events. |
| 1372 | CounterValues counter_values_; |
Primiano Tucci | 5cb84f8 | 2018-10-31 21:46:36 -0700 | [diff] [blame] | 1373 | |
| 1374 | SqlStats sql_stats_; |
Lalit Maganti | 6e9c55e | 2018-11-29 12:00:39 +0000 | [diff] [blame] | 1375 | |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 1376 | // These are instantaneous events in the trace. They have no duration |
| 1377 | // and do not have a value that make sense to track over time. |
| 1378 | // e.g. signal events |
| 1379 | Instants instants_; |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 1380 | |
| 1381 | // Raw events are every ftrace event in the trace. The raw event includes |
| 1382 | // the timestamp and the pid. The args for the raw event will be in the |
| 1383 | // args table. This table can be used to generate a text version of the |
| 1384 | // trace. |
| 1385 | RawEvents raw_events_; |
Primiano Tucci | 2c761ef | 2019-01-07 20:20:46 +0000 | [diff] [blame] | 1386 | AndroidLogs android_log_; |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 1387 | |
Oystein Eftevaag | 5419c58 | 2019-08-21 13:58:49 -0700 | [diff] [blame] | 1388 | StackProfileMappings stack_profile_mappings_; |
| 1389 | StackProfileFrames stack_profile_frames_; |
| 1390 | StackProfileCallsites stack_profile_callsites_; |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 1391 | HeapProfileAllocations heap_profile_allocations_; |
Oystein Eftevaag | 7f64c10 | 2019-08-29 10:27:31 -0700 | [diff] [blame] | 1392 | CpuProfileStackSamples cpu_profile_stack_samples_; |
Ioannis Ilkos | e0b47f5 | 2019-09-18 11:14:57 +0100 | [diff] [blame] | 1393 | |
| 1394 | // Symbol tables (mappings from frames to symbol names) |
| 1395 | tables::SymbolTable symbol_table_{&string_pool_, nullptr}; |
Florian Mayer | 25e013e | 2019-10-01 14:06:15 +0100 | [diff] [blame^] | 1396 | tables::HeapGraphObjectTable heap_graph_object_table_{&string_pool_, nullptr}; |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 1397 | }; |
| 1398 | |
| 1399 | } // namespace trace_processor |
| 1400 | } // namespace perfetto |
| 1401 | |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 1402 | namespace std { |
| 1403 | |
| 1404 | template <> |
Oystein Eftevaag | 5419c58 | 2019-08-21 13:58:49 -0700 | [diff] [blame] | 1405 | struct hash< |
| 1406 | ::perfetto::trace_processor::TraceStorage::StackProfileFrames::Row> { |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 1407 | using argument_type = |
Oystein Eftevaag | 5419c58 | 2019-08-21 13:58:49 -0700 | [diff] [blame] | 1408 | ::perfetto::trace_processor::TraceStorage::StackProfileFrames::Row; |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 1409 | using result_type = size_t; |
| 1410 | |
| 1411 | result_type operator()(const argument_type& r) const { |
| 1412 | return std::hash<::perfetto::trace_processor::StringId>{}(r.name_id) ^ |
| 1413 | std::hash<int64_t>{}(r.mapping_row) ^ std::hash<int64_t>{}(r.rel_pc); |
| 1414 | } |
| 1415 | }; |
| 1416 | |
| 1417 | template <> |
| 1418 | struct hash< |
Oystein Eftevaag | 5419c58 | 2019-08-21 13:58:49 -0700 | [diff] [blame] | 1419 | ::perfetto::trace_processor::TraceStorage::StackProfileCallsites::Row> { |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 1420 | using argument_type = |
Oystein Eftevaag | 5419c58 | 2019-08-21 13:58:49 -0700 | [diff] [blame] | 1421 | ::perfetto::trace_processor::TraceStorage::StackProfileCallsites::Row; |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 1422 | using result_type = size_t; |
| 1423 | |
| 1424 | result_type operator()(const argument_type& r) const { |
| 1425 | return std::hash<int64_t>{}(r.depth) ^ std::hash<int64_t>{}(r.parent_id) ^ |
| 1426 | std::hash<int64_t>{}(r.frame_row); |
| 1427 | } |
| 1428 | }; |
| 1429 | |
| 1430 | template <> |
| 1431 | struct hash< |
Oystein Eftevaag | 5419c58 | 2019-08-21 13:58:49 -0700 | [diff] [blame] | 1432 | ::perfetto::trace_processor::TraceStorage::StackProfileMappings::Row> { |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 1433 | using argument_type = |
Oystein Eftevaag | 5419c58 | 2019-08-21 13:58:49 -0700 | [diff] [blame] | 1434 | ::perfetto::trace_processor::TraceStorage::StackProfileMappings::Row; |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 1435 | using result_type = size_t; |
| 1436 | |
| 1437 | result_type operator()(const argument_type& r) const { |
| 1438 | return std::hash<::perfetto::trace_processor::StringId>{}(r.build_id) ^ |
Florian Mayer | 1265573 | 2019-07-02 15:08:26 +0100 | [diff] [blame] | 1439 | std::hash<int64_t>{}(r.exact_offset) ^ |
| 1440 | std::hash<int64_t>{}(r.start_offset) ^ |
| 1441 | std::hash<int64_t>{}(r.start) ^ std::hash<int64_t>{}(r.end) ^ |
| 1442 | std::hash<int64_t>{}(r.load_bias) ^ |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 1443 | std::hash<::perfetto::trace_processor::StringId>{}(r.name_id); |
| 1444 | } |
| 1445 | }; |
| 1446 | |
| 1447 | } // namespace std |
| 1448 | |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 1449 | #endif // SRC_TRACE_PROCESSOR_TRACE_STORAGE_H_ |