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" |
Eric Seckler | f93b8cf | 2019-11-20 21:33:01 +0000 | [diff] [blame] | 34 | #include "perfetto/trace_processor/basic_types.h" |
Lalit Maganti | 9ecfab3 | 2019-12-17 17:45:38 +0000 | [diff] [blame] | 35 | #include "src/trace_processor/containers/string_pool.h" |
Lalit Maganti | b0b53ee | 2019-01-24 17:53:39 +0000 | [diff] [blame] | 36 | #include "src/trace_processor/ftrace_utils.h" |
Mikhail Khokhlov | e466c00 | 2019-05-23 13:33:33 +0100 | [diff] [blame] | 37 | #include "src/trace_processor/metadata.h" |
Primiano Tucci | 0e38a14 | 2019-01-07 20:51:09 +0000 | [diff] [blame] | 38 | #include "src/trace_processor/stats.h" |
Lalit Maganti | 4b3b3ad | 2019-12-04 19:27:35 +0000 | [diff] [blame] | 39 | #include "src/trace_processor/tables/counter_tables.h" |
Ioannis Ilkos | e0b47f5 | 2019-09-18 11:14:57 +0100 | [diff] [blame] | 40 | #include "src/trace_processor/tables/profiler_tables.h" |
Lalit Maganti | 20539c2 | 2019-09-04 12:36:10 +0100 | [diff] [blame] | 41 | #include "src/trace_processor/tables/slice_tables.h" |
| 42 | #include "src/trace_processor/tables/track_tables.h" |
Mikhail Khokhlov | 85a0dd0 | 2019-05-17 14:22:28 +0100 | [diff] [blame] | 43 | #include "src/trace_processor/variadic.h" |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 44 | |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 45 | namespace perfetto { |
| 46 | namespace trace_processor { |
| 47 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 48 | // UniquePid is an offset into |unique_processes_|. This is necessary because |
| 49 | // Unix pids are reused and thus not guaranteed to be unique over a long |
| 50 | // period of time. |
| 51 | using UniquePid = uint32_t; |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 52 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 53 | // UniqueTid is an offset into |unique_threads_|. Necessary because tids can |
| 54 | // be reused. |
| 55 | using UniqueTid = uint32_t; |
| 56 | |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 57 | // StringId is an offset into |string_pool_|. |
Lalit Maganti | 5c45431 | 2019-04-08 12:11:17 +0100 | [diff] [blame] | 58 | using StringId = StringPool::Id; |
Lalit Maganti | 1a2936f | 2019-08-29 17:42:33 +0100 | [diff] [blame] | 59 | static const StringId kNullStringId = StringId(0); |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 60 | |
Lalit Maganti | 5ea9e93 | 2018-11-30 14:19:39 +0000 | [diff] [blame] | 61 | // Identifiers for all the tables in the database. |
Lalit Maganti | 7449dc8 | 2019-12-30 15:52:35 +0000 | [diff] [blame] | 62 | enum class TableId : uint8_t { |
| 63 | kInvalid = 0, |
Lalit Maganti | 8320e6d | 2019-03-14 18:49:33 +0000 | [diff] [blame] | 64 | kCounterValues = 1, |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 65 | kRawEvents = 2, |
Lalit Maganti | 66ed7ad | 2019-01-11 16:47:26 +0000 | [diff] [blame] | 66 | kInstants = 3, |
Isabelle Taylor | b9222c3 | 2019-01-31 10:58:37 +0000 | [diff] [blame] | 67 | kSched = 4, |
Eric Seckler | 70cc442 | 2019-05-28 16:00:23 +0100 | [diff] [blame] | 68 | kNestableSlices = 5, |
Ryan Savitski | 51413ad | 2019-07-09 14:25:21 +0100 | [diff] [blame] | 69 | kMetadataTable = 6, |
Lalit Maganti | 53bdbb2 | 2019-09-25 11:11:18 +0100 | [diff] [blame] | 70 | kTrack = 7, |
Mohammad Reza Zakerinasab | b06d185 | 2019-09-11 14:41:36 -0400 | [diff] [blame] | 71 | kVulkanMemoryAllocation = 8, |
Lalit Maganti | 5ea9e93 | 2018-11-30 14:19:39 +0000 | [diff] [blame] | 72 | }; |
| 73 | |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 74 | using ArgSetId = uint32_t; |
| 75 | static const ArgSetId kInvalidArgSetId = 0; |
| 76 | |
Lalit Maganti | b0e11f6 | 2020-01-02 14:17:58 +0000 | [diff] [blame] | 77 | using TrackId = tables::TrackTable::Id; |
| 78 | |
| 79 | using CounterId = tables::CounterTable::Id; |
| 80 | |
| 81 | using SliceId = tables::SliceTable::Id; |
| 82 | |
| 83 | using MappingId = tables::StackProfileMappingTable::Id; |
Eric Seckler | 5703ede | 2019-07-10 10:13:02 +0100 | [diff] [blame] | 84 | |
Lalit Maganti | 809b2f9 | 2019-11-07 13:27:26 +0000 | [diff] [blame] | 85 | // TODO(lalitm): this is a temporary hack while migrating the counters table and |
| 86 | // will be removed when the migration is complete. |
Lalit Maganti | b0e11f6 | 2020-01-02 14:17:58 +0000 | [diff] [blame] | 87 | static const TrackId kInvalidTrackId = |
| 88 | TrackId(std::numeric_limits<TrackId>::max()); |
Lalit Maganti | 809b2f9 | 2019-11-07 13:27:26 +0000 | [diff] [blame] | 89 | |
Lalit Maganti | 21b2163 | 2019-09-28 16:50:23 +0100 | [diff] [blame] | 90 | enum class RefType { |
Primiano Tucci | 5403e4f | 2018-11-27 10:07:03 +0000 | [diff] [blame] | 91 | kRefNoRef = 0, |
| 92 | kRefUtid = 1, |
| 93 | kRefCpuId = 2, |
| 94 | kRefIrq = 3, |
| 95 | kRefSoftIrq = 4, |
| 96 | kRefUpid = 5, |
Sidath Senanayake | 1f5f93a | 2019-06-06 22:24:15 +0100 | [diff] [blame] | 97 | kRefGpuId = 6, |
Eric Seckler | 5703ede | 2019-07-10 10:13:02 +0100 | [diff] [blame] | 98 | kRefTrack = 7, |
Primiano Tucci | 5403e4f | 2018-11-27 10:07:03 +0000 | [diff] [blame] | 99 | kRefMax |
Isabelle Taylor | a97c5f5 | 2018-10-23 17:36:12 +0100 | [diff] [blame] | 100 | }; |
Isabelle Taylor | 14674d4 | 2018-09-07 11:33:11 +0100 | [diff] [blame] | 101 | |
Lalit Maganti | b134d25 | 2019-12-10 12:21:27 +0000 | [diff] [blame] | 102 | const std::vector<NullTermStringView>& GetRefTypeStringMap(); |
Eric Seckler | 972225e | 2019-04-18 11:07:12 +0100 | [diff] [blame] | 103 | |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 104 | // Stores a data inside a trace file in a columnar form. This makes it efficient |
| 105 | // to read or search across a single field of the trace (e.g. all the thread |
| 106 | // names for a given CPU). |
| 107 | class TraceStorage { |
| 108 | public: |
Eric Seckler | f93b8cf | 2019-11-20 21:33:01 +0000 | [diff] [blame] | 109 | TraceStorage(const Config& = Config()); |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 110 | |
| 111 | virtual ~TraceStorage(); |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 112 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 113 | // Information about a unique process seen in a trace. |
| 114 | struct Process { |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 115 | explicit Process(uint32_t p) : pid(p) {} |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 116 | int64_t start_ns = 0; |
Lalit Maganti | 637589a | 2019-07-04 17:25:29 +0100 | [diff] [blame] | 117 | int64_t end_ns = 0; |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 118 | StringId name_id = 0; |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 119 | uint32_t pid = 0; |
Lalit Maganti | 369b057 | 2019-07-11 15:35:09 +0100 | [diff] [blame] | 120 | base::Optional<UniquePid> parent_upid; |
Ioannis Ilkos | fd554bc | 2019-11-16 01:14:57 +0000 | [diff] [blame] | 121 | base::Optional<uint32_t> uid; |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 122 | }; |
| 123 | |
| 124 | // Information about a unique thread seen in a trace. |
| 125 | struct Thread { |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 126 | explicit Thread(uint32_t t) : tid(t) {} |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 127 | int64_t start_ns = 0; |
Lalit Maganti | b5bd233 | 2019-06-06 14:20:47 +0100 | [diff] [blame] | 128 | int64_t end_ns = 0; |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 129 | StringId name_id = 0; |
Lalit Maganti | 770886a | 2018-11-16 17:40:21 +0000 | [diff] [blame] | 130 | base::Optional<UniquePid> upid; |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 131 | uint32_t tid = 0; |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 132 | }; |
Isabelle Taylor | 3dd366c | 2018-06-22 16:21:41 +0100 | [diff] [blame] | 133 | |
Lalit Maganti | 6e9c55e | 2018-11-29 12:00:39 +0000 | [diff] [blame] | 134 | // Generic key value storage which can be referenced by other tables. |
| 135 | class Args { |
| 136 | public: |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 137 | struct Arg { |
| 138 | StringId flat_key = 0; |
| 139 | StringId key = 0; |
| 140 | Variadic value = Variadic::Integer(0); |
| 141 | |
Lalit Maganti | 7449dc8 | 2019-12-30 15:52:35 +0000 | [diff] [blame] | 142 | TableId table; |
| 143 | uint32_t row; |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 144 | }; |
| 145 | |
| 146 | struct ArgHasher { |
| 147 | uint64_t operator()(const Arg& arg) const noexcept { |
Lalit Maganti | 1f46474 | 2019-02-28 13:49:31 +0000 | [diff] [blame] | 148 | base::Hash hash; |
| 149 | hash.Update(arg.key); |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 150 | // We don't hash arg.flat_key because it's a subsequence of arg.key. |
| 151 | switch (arg.value.type) { |
| 152 | case Variadic::Type::kInt: |
Lalit Maganti | 1f46474 | 2019-02-28 13:49:31 +0000 | [diff] [blame] | 153 | hash.Update(arg.value.int_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::kUint: |
| 156 | hash.Update(arg.value.uint_value); |
| 157 | break; |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 158 | case Variadic::Type::kString: |
Lalit Maganti | 1f46474 | 2019-02-28 13:49:31 +0000 | [diff] [blame] | 159 | hash.Update(arg.value.string_value); |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 160 | break; |
| 161 | case Variadic::Type::kReal: |
Lalit Maganti | 1f46474 | 2019-02-28 13:49:31 +0000 | [diff] [blame] | 162 | hash.Update(arg.value.real_value); |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 163 | break; |
Eric Seckler | c93823e | 2019-06-03 16:49:19 +0100 | [diff] [blame] | 164 | case Variadic::Type::kPointer: |
| 165 | hash.Update(arg.value.pointer_value); |
| 166 | break; |
| 167 | case Variadic::Type::kBool: |
| 168 | hash.Update(arg.value.bool_value); |
| 169 | break; |
| 170 | case Variadic::Type::kJson: |
| 171 | hash.Update(arg.value.json_value); |
| 172 | break; |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 173 | } |
Lalit Maganti | 1f46474 | 2019-02-28 13:49:31 +0000 | [diff] [blame] | 174 | return hash.digest(); |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 175 | } |
| 176 | }; |
| 177 | |
| 178 | const std::deque<ArgSetId>& set_ids() const { return set_ids_; } |
Lalit Maganti | 5ea9e93 | 2018-11-30 14:19:39 +0000 | [diff] [blame] | 179 | const std::deque<StringId>& flat_keys() const { return flat_keys_; } |
| 180 | const std::deque<StringId>& keys() const { return keys_; } |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 181 | const std::deque<Variadic>& arg_values() const { return arg_values_; } |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 182 | uint32_t args_count() const { |
| 183 | return static_cast<uint32_t>(set_ids_.size()); |
Lalit Maganti | 79472be | 2018-12-04 13:41:27 +0000 | [diff] [blame] | 184 | } |
Lalit Maganti | 6e9c55e | 2018-11-29 12:00:39 +0000 | [diff] [blame] | 185 | |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 186 | ArgSetId AddArgSet(const std::vector<Arg>& args, |
| 187 | uint32_t begin, |
| 188 | uint32_t end) { |
Lalit Maganti | 1f46474 | 2019-02-28 13:49:31 +0000 | [diff] [blame] | 189 | base::Hash hash; |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 190 | for (uint32_t i = begin; i < end; i++) { |
Lalit Maganti | 1f46474 | 2019-02-28 13:49:31 +0000 | [diff] [blame] | 191 | hash.Update(ArgHasher()(args[i])); |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 192 | } |
Lalit Maganti | 5ea9e93 | 2018-11-30 14:19:39 +0000 | [diff] [blame] | 193 | |
Lalit Maganti | 1f46474 | 2019-02-28 13:49:31 +0000 | [diff] [blame] | 194 | ArgSetHash digest = hash.digest(); |
| 195 | auto it = arg_row_for_hash_.find(digest); |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 196 | if (it != arg_row_for_hash_.end()) { |
| 197 | return set_ids_[it->second]; |
| 198 | } |
| 199 | |
| 200 | // The +1 ensures that nothing has an id == kInvalidArgSetId == 0. |
| 201 | ArgSetId id = static_cast<uint32_t>(arg_row_for_hash_.size()) + 1; |
Lalit Maganti | 1f46474 | 2019-02-28 13:49:31 +0000 | [diff] [blame] | 202 | arg_row_for_hash_.emplace(digest, args_count()); |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 203 | for (uint32_t i = begin; i < end; i++) { |
| 204 | const auto& arg = args[i]; |
| 205 | set_ids_.emplace_back(id); |
| 206 | flat_keys_.emplace_back(arg.flat_key); |
| 207 | keys_.emplace_back(arg.key); |
| 208 | arg_values_.emplace_back(arg.value); |
| 209 | } |
| 210 | return id; |
Lalit Maganti | 6e9c55e | 2018-11-29 12:00:39 +0000 | [diff] [blame] | 211 | } |
| 212 | |
Lalit Maganti | 5ea9e93 | 2018-11-30 14:19:39 +0000 | [diff] [blame] | 213 | private: |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 214 | using ArgSetHash = uint64_t; |
| 215 | |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 216 | std::deque<ArgSetId> set_ids_; |
Lalit Maganti | 5ea9e93 | 2018-11-30 14:19:39 +0000 | [diff] [blame] | 217 | std::deque<StringId> flat_keys_; |
| 218 | std::deque<StringId> keys_; |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 219 | std::deque<Variadic> arg_values_; |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 220 | |
| 221 | std::unordered_map<ArgSetHash, uint32_t> arg_row_for_hash_; |
Lalit Maganti | 6e9c55e | 2018-11-29 12:00:39 +0000 | [diff] [blame] | 222 | }; |
| 223 | |
Lalit Maganti | ff69c11 | 2018-09-24 12:07:47 +0100 | [diff] [blame] | 224 | class Slices { |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 225 | public: |
Lalit Maganti | fde2904 | 2018-10-04 13:28:52 +0100 | [diff] [blame] | 226 | inline size_t AddSlice(uint32_t cpu, |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 227 | int64_t start_ns, |
| 228 | int64_t duration_ns, |
Lalit Maganti | b0b53ee | 2019-01-24 17:53:39 +0000 | [diff] [blame] | 229 | UniqueTid utid, |
| 230 | ftrace_utils::TaskState end_state, |
| 231 | int32_t priority) { |
Lalit Maganti | ff69c11 | 2018-09-24 12:07:47 +0100 | [diff] [blame] | 232 | cpus_.emplace_back(cpu); |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 233 | start_ns_.emplace_back(start_ns); |
| 234 | durations_.emplace_back(duration_ns); |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 235 | utids_.emplace_back(utid); |
Lalit Maganti | b0b53ee | 2019-01-24 17:53:39 +0000 | [diff] [blame] | 236 | end_states_.emplace_back(end_state); |
| 237 | priorities_.emplace_back(priority); |
Lalit Maganti | 5863893 | 2019-01-31 10:48:26 +0000 | [diff] [blame] | 238 | |
| 239 | if (utid >= rows_for_utids_.size()) |
| 240 | rows_for_utids_.resize(utid + 1); |
| 241 | rows_for_utids_[utid].emplace_back(slice_count() - 1); |
Lalit Maganti | fde2904 | 2018-10-04 13:28:52 +0100 | [diff] [blame] | 242 | return slice_count() - 1; |
| 243 | } |
| 244 | |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 245 | void set_duration(size_t index, int64_t duration_ns) { |
Lalit Maganti | fde2904 | 2018-10-04 13:28:52 +0100 | [diff] [blame] | 246 | durations_[index] = duration_ns; |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 247 | } |
| 248 | |
Lalit Maganti | b0b53ee | 2019-01-24 17:53:39 +0000 | [diff] [blame] | 249 | void set_end_state(size_t index, ftrace_utils::TaskState end_state) { |
| 250 | end_states_[index] = end_state; |
| 251 | } |
| 252 | |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 253 | size_t slice_count() const { return start_ns_.size(); } |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 254 | |
Lalit Maganti | ff69c11 | 2018-09-24 12:07:47 +0100 | [diff] [blame] | 255 | const std::deque<uint32_t>& cpus() const { return cpus_; } |
| 256 | |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 257 | const std::deque<int64_t>& start_ns() const { return start_ns_; } |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 258 | |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 259 | const std::deque<int64_t>& durations() const { return durations_; } |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 260 | |
Isabelle Taylor | 68e4219 | 2018-06-19 16:19:31 +0100 | [diff] [blame] | 261 | const std::deque<UniqueTid>& utids() const { return utids_; } |
| 262 | |
Lalit Maganti | b0b53ee | 2019-01-24 17:53:39 +0000 | [diff] [blame] | 263 | const std::deque<ftrace_utils::TaskState>& end_state() const { |
| 264 | return end_states_; |
| 265 | } |
| 266 | |
| 267 | const std::deque<int32_t>& priorities() const { return priorities_; } |
| 268 | |
Lalit Maganti | 5863893 | 2019-01-31 10:48:26 +0000 | [diff] [blame] | 269 | const std::deque<std::vector<uint32_t>>& rows_for_utids() const { |
Lalit Maganti | f0f09c3 | 2019-01-18 17:29:31 +0000 | [diff] [blame] | 270 | return rows_for_utids_; |
| 271 | } |
| 272 | |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 273 | private: |
Hector Dearman | 947f12a | 2018-09-11 16:50:36 +0100 | [diff] [blame] | 274 | // 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] | 275 | // in the trace for the CPU). |
Lalit Maganti | ff69c11 | 2018-09-24 12:07:47 +0100 | [diff] [blame] | 276 | std::deque<uint32_t> cpus_; |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 277 | std::deque<int64_t> start_ns_; |
| 278 | std::deque<int64_t> durations_; |
Isabelle Taylor | 68e4219 | 2018-06-19 16:19:31 +0100 | [diff] [blame] | 279 | std::deque<UniqueTid> utids_; |
Lalit Maganti | b0b53ee | 2019-01-24 17:53:39 +0000 | [diff] [blame] | 280 | std::deque<ftrace_utils::TaskState> end_states_; |
| 281 | std::deque<int32_t> priorities_; |
Lalit Maganti | 5863893 | 2019-01-31 10:48:26 +0000 | [diff] [blame] | 282 | |
| 283 | // One row per utid. |
| 284 | std::deque<std::vector<uint32_t>> rows_for_utids_; |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 285 | }; |
Isabelle Taylor | 68e4219 | 2018-06-19 16:19:31 +0100 | [diff] [blame] | 286 | |
Eric Seckler | d3b89d5 | 2019-07-10 15:36:29 +0100 | [diff] [blame] | 287 | class ThreadSlices { |
| 288 | public: |
| 289 | inline uint32_t AddThreadSlice(uint32_t slice_id, |
| 290 | int64_t thread_timestamp_ns, |
| 291 | int64_t thread_duration_ns, |
| 292 | int64_t thread_instruction_count, |
| 293 | int64_t thread_instruction_delta) { |
| 294 | slice_ids_.emplace_back(slice_id); |
| 295 | thread_timestamp_ns_.emplace_back(thread_timestamp_ns); |
| 296 | thread_duration_ns_.emplace_back(thread_duration_ns); |
| 297 | thread_instruction_counts_.emplace_back(thread_instruction_count); |
| 298 | thread_instruction_deltas_.emplace_back(thread_instruction_delta); |
| 299 | return slice_count() - 1; |
| 300 | } |
| 301 | |
Eric Seckler | c3430c6 | 2019-07-22 10:49:58 +0100 | [diff] [blame] | 302 | uint32_t slice_count() const { |
| 303 | return static_cast<uint32_t>(slice_ids_.size()); |
Eric Seckler | d3b89d5 | 2019-07-10 15:36:29 +0100 | [diff] [blame] | 304 | } |
| 305 | |
Eric Seckler | c3430c6 | 2019-07-22 10:49:58 +0100 | [diff] [blame] | 306 | const std::deque<uint32_t>& slice_ids() const { return slice_ids_; } |
| 307 | const std::deque<int64_t>& thread_timestamp_ns() const { |
| 308 | return thread_timestamp_ns_; |
| 309 | } |
| 310 | const std::deque<int64_t>& thread_duration_ns() const { |
| 311 | return thread_duration_ns_; |
| 312 | } |
| 313 | const std::deque<int64_t>& thread_instruction_counts() const { |
| 314 | return thread_instruction_counts_; |
| 315 | } |
| 316 | const std::deque<int64_t>& thread_instruction_deltas() const { |
| 317 | return thread_instruction_deltas_; |
| 318 | } |
| 319 | |
| 320 | base::Optional<uint32_t> FindRowForSliceId(uint32_t slice_id) const { |
| 321 | auto it = |
| 322 | std::lower_bound(slice_ids().begin(), slice_ids().end(), slice_id); |
| 323 | if (it != slice_ids().end() && *it == slice_id) { |
| 324 | return static_cast<uint32_t>(std::distance(slice_ids().begin(), it)); |
| 325 | } |
| 326 | return base::nullopt; |
| 327 | } |
| 328 | |
Eric Seckler | 54f30a3 | 2019-07-19 15:10:29 +0100 | [diff] [blame] | 329 | void UpdateThreadDeltasForSliceId(uint32_t slice_id, |
| 330 | int64_t end_thread_timestamp_ns, |
| 331 | int64_t end_thread_instruction_count) { |
Eric Seckler | c3430c6 | 2019-07-22 10:49:58 +0100 | [diff] [blame] | 332 | uint32_t row = *FindRowForSliceId(slice_id); |
| 333 | int64_t begin_ns = thread_timestamp_ns_[row]; |
| 334 | thread_duration_ns_[row] = end_thread_timestamp_ns - begin_ns; |
Eric Seckler | 54f30a3 | 2019-07-19 15:10:29 +0100 | [diff] [blame] | 335 | int64_t begin_ticount = thread_instruction_counts_[row]; |
| 336 | thread_instruction_deltas_[row] = |
| 337 | end_thread_instruction_count - begin_ticount; |
Eric Seckler | c3430c6 | 2019-07-22 10:49:58 +0100 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | private: |
| 341 | std::deque<uint32_t> slice_ids_; |
| 342 | std::deque<int64_t> thread_timestamp_ns_; |
| 343 | std::deque<int64_t> thread_duration_ns_; |
| 344 | std::deque<int64_t> thread_instruction_counts_; |
| 345 | std::deque<int64_t> thread_instruction_deltas_; |
| 346 | }; |
| 347 | |
| 348 | class VirtualTrackSlices { |
| 349 | public: |
| 350 | inline uint32_t AddVirtualTrackSlice(uint32_t slice_id, |
| 351 | int64_t thread_timestamp_ns, |
| 352 | int64_t thread_duration_ns, |
| 353 | int64_t thread_instruction_count, |
| 354 | int64_t thread_instruction_delta) { |
| 355 | slice_ids_.emplace_back(slice_id); |
| 356 | thread_timestamp_ns_.emplace_back(thread_timestamp_ns); |
| 357 | thread_duration_ns_.emplace_back(thread_duration_ns); |
| 358 | thread_instruction_counts_.emplace_back(thread_instruction_count); |
| 359 | thread_instruction_deltas_.emplace_back(thread_instruction_delta); |
| 360 | return slice_count() - 1; |
Eric Seckler | d3b89d5 | 2019-07-10 15:36:29 +0100 | [diff] [blame] | 361 | } |
| 362 | |
| 363 | uint32_t slice_count() const { |
| 364 | return static_cast<uint32_t>(slice_ids_.size()); |
| 365 | } |
| 366 | |
| 367 | const std::deque<uint32_t>& slice_ids() const { return slice_ids_; } |
| 368 | const std::deque<int64_t>& thread_timestamp_ns() const { |
| 369 | return thread_timestamp_ns_; |
| 370 | } |
| 371 | const std::deque<int64_t>& thread_duration_ns() const { |
| 372 | return thread_duration_ns_; |
| 373 | } |
| 374 | const std::deque<int64_t>& thread_instruction_counts() const { |
| 375 | return thread_instruction_counts_; |
| 376 | } |
| 377 | const std::deque<int64_t>& thread_instruction_deltas() const { |
| 378 | return thread_instruction_deltas_; |
| 379 | } |
| 380 | |
Mikhail Khokhlov | 7db0491 | 2019-07-18 16:11:11 +0100 | [diff] [blame] | 381 | base::Optional<uint32_t> FindRowForSliceId(uint32_t slice_id) const { |
Eric Seckler | d3b89d5 | 2019-07-10 15:36:29 +0100 | [diff] [blame] | 382 | auto it = |
| 383 | std::lower_bound(slice_ids().begin(), slice_ids().end(), slice_id); |
Mikhail Khokhlov | 7db0491 | 2019-07-18 16:11:11 +0100 | [diff] [blame] | 384 | if (it != slice_ids().end() && *it == slice_id) { |
| 385 | return static_cast<uint32_t>(std::distance(slice_ids().begin(), it)); |
| 386 | } |
| 387 | return base::nullopt; |
Eric Seckler | d3b89d5 | 2019-07-10 15:36:29 +0100 | [diff] [blame] | 388 | } |
| 389 | |
Eric Seckler | 54f30a3 | 2019-07-19 15:10:29 +0100 | [diff] [blame] | 390 | void UpdateThreadDeltasForSliceId(uint32_t slice_id, |
| 391 | int64_t end_thread_timestamp_ns, |
| 392 | int64_t end_thread_instruction_count) { |
Mikhail Khokhlov | 7db0491 | 2019-07-18 16:11:11 +0100 | [diff] [blame] | 393 | uint32_t row = *FindRowForSliceId(slice_id); |
Eric Seckler | d3b89d5 | 2019-07-10 15:36:29 +0100 | [diff] [blame] | 394 | int64_t begin_ns = thread_timestamp_ns_[row]; |
| 395 | thread_duration_ns_[row] = end_thread_timestamp_ns - begin_ns; |
Eric Seckler | 54f30a3 | 2019-07-19 15:10:29 +0100 | [diff] [blame] | 396 | int64_t begin_ticount = thread_instruction_counts_[row]; |
| 397 | thread_instruction_deltas_[row] = |
| 398 | end_thread_instruction_count - begin_ticount; |
Eric Seckler | d3b89d5 | 2019-07-10 15:36:29 +0100 | [diff] [blame] | 399 | } |
| 400 | |
| 401 | private: |
| 402 | std::deque<uint32_t> slice_ids_; |
| 403 | std::deque<int64_t> thread_timestamp_ns_; |
| 404 | std::deque<int64_t> thread_duration_ns_; |
| 405 | std::deque<int64_t> thread_instruction_counts_; |
| 406 | std::deque<int64_t> thread_instruction_deltas_; |
| 407 | }; |
| 408 | |
Primiano Tucci | 5cb84f8 | 2018-10-31 21:46:36 -0700 | [diff] [blame] | 409 | class SqlStats { |
| 410 | public: |
| 411 | static constexpr size_t kMaxLogEntries = 100; |
Lalit Maganti | aac2f65 | 2019-04-30 12:16:21 +0100 | [diff] [blame] | 412 | uint32_t RecordQueryBegin(const std::string& query, |
| 413 | int64_t time_queued, |
| 414 | int64_t time_started); |
| 415 | void RecordQueryFirstNext(uint32_t row, int64_t time_first_next); |
| 416 | void RecordQueryEnd(uint32_t row, int64_t time_end); |
Primiano Tucci | 5cb84f8 | 2018-10-31 21:46:36 -0700 | [diff] [blame] | 417 | size_t size() const { return queries_.size(); } |
| 418 | const std::deque<std::string>& queries() const { return queries_; } |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 419 | const std::deque<int64_t>& times_queued() const { return times_queued_; } |
| 420 | const std::deque<int64_t>& times_started() const { return times_started_; } |
Lalit Maganti | aac2f65 | 2019-04-30 12:16:21 +0100 | [diff] [blame] | 421 | const std::deque<int64_t>& times_first_next() const { |
| 422 | return times_first_next_; |
| 423 | } |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 424 | const std::deque<int64_t>& times_ended() const { return times_ended_; } |
Primiano Tucci | 5cb84f8 | 2018-10-31 21:46:36 -0700 | [diff] [blame] | 425 | |
| 426 | private: |
Lalit Maganti | aac2f65 | 2019-04-30 12:16:21 +0100 | [diff] [blame] | 427 | uint32_t popped_queries_ = 0; |
| 428 | |
Primiano Tucci | 5cb84f8 | 2018-10-31 21:46:36 -0700 | [diff] [blame] | 429 | std::deque<std::string> queries_; |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 430 | std::deque<int64_t> times_queued_; |
| 431 | std::deque<int64_t> times_started_; |
Lalit Maganti | aac2f65 | 2019-04-30 12:16:21 +0100 | [diff] [blame] | 432 | std::deque<int64_t> times_first_next_; |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 433 | std::deque<int64_t> times_ended_; |
Primiano Tucci | 5cb84f8 | 2018-10-31 21:46:36 -0700 | [diff] [blame] | 434 | }; |
| 435 | |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 436 | class Instants { |
| 437 | public: |
Lalit Maganti | 66ed7ad | 2019-01-11 16:47:26 +0000 | [diff] [blame] | 438 | inline uint32_t AddInstantEvent(int64_t timestamp, |
| 439 | StringId name_id, |
| 440 | double value, |
| 441 | int64_t ref, |
| 442 | RefType type) { |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 443 | timestamps_.emplace_back(timestamp); |
| 444 | name_ids_.emplace_back(name_id); |
| 445 | values_.emplace_back(value); |
| 446 | refs_.emplace_back(ref); |
| 447 | types_.emplace_back(type); |
Lalit Maganti | 1c21d17 | 2019-02-07 10:48:24 +0000 | [diff] [blame] | 448 | arg_set_ids_.emplace_back(kInvalidArgSetId); |
Lalit Maganti | 66ed7ad | 2019-01-11 16:47:26 +0000 | [diff] [blame] | 449 | return static_cast<uint32_t>(instant_count() - 1); |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 450 | } |
| 451 | |
Lalit Maganti | 521d97b | 2019-04-29 13:47:03 +0100 | [diff] [blame] | 452 | void set_ref(uint32_t row, int64_t ref) { refs_[row] = ref; } |
| 453 | |
Lalit Maganti | 1c21d17 | 2019-02-07 10:48:24 +0000 | [diff] [blame] | 454 | void set_arg_set_id(uint32_t row, ArgSetId id) { arg_set_ids_[row] = id; } |
| 455 | |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 456 | size_t instant_count() const { return timestamps_.size(); } |
| 457 | |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 458 | const std::deque<int64_t>& timestamps() const { return timestamps_; } |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 459 | |
| 460 | const std::deque<StringId>& name_ids() const { return name_ids_; } |
| 461 | |
| 462 | const std::deque<double>& values() const { return values_; } |
| 463 | |
| 464 | const std::deque<int64_t>& refs() const { return refs_; } |
| 465 | |
| 466 | const std::deque<RefType>& types() const { return types_; } |
| 467 | |
Lalit Maganti | 1c21d17 | 2019-02-07 10:48:24 +0000 | [diff] [blame] | 468 | const std::deque<ArgSetId>& arg_set_ids() const { return arg_set_ids_; } |
| 469 | |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 470 | private: |
Lalit Maganti | 85ca4a8 | 2018-12-07 17:28:02 +0000 | [diff] [blame] | 471 | std::deque<int64_t> timestamps_; |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 472 | std::deque<StringId> name_ids_; |
| 473 | std::deque<double> values_; |
| 474 | std::deque<int64_t> refs_; |
| 475 | std::deque<RefType> types_; |
Lalit Maganti | 1c21d17 | 2019-02-07 10:48:24 +0000 | [diff] [blame] | 476 | std::deque<ArgSetId> arg_set_ids_; |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 477 | }; |
| 478 | |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 479 | class RawEvents { |
| 480 | public: |
Lalit Maganti | 7449dc8 | 2019-12-30 15:52:35 +0000 | [diff] [blame] | 481 | inline uint32_t AddRawEvent(int64_t timestamp, |
| 482 | StringId name_id, |
| 483 | uint32_t cpu, |
| 484 | UniqueTid utid) { |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 485 | timestamps_.emplace_back(timestamp); |
| 486 | name_ids_.emplace_back(name_id); |
Lalit Maganti | e87cc81 | 2019-01-10 15:20:06 +0000 | [diff] [blame] | 487 | cpus_.emplace_back(cpu); |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 488 | utids_.emplace_back(utid); |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 489 | arg_set_ids_.emplace_back(kInvalidArgSetId); |
Lalit Maganti | 7449dc8 | 2019-12-30 15:52:35 +0000 | [diff] [blame] | 490 | return static_cast<uint32_t>(raw_event_count() - 1); |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 491 | } |
| 492 | |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 493 | void set_arg_set_id(uint32_t row, ArgSetId id) { arg_set_ids_[row] = id; } |
| 494 | |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 495 | size_t raw_event_count() const { return timestamps_.size(); } |
| 496 | |
| 497 | const std::deque<int64_t>& timestamps() const { return timestamps_; } |
| 498 | |
| 499 | const std::deque<StringId>& name_ids() const { return name_ids_; } |
| 500 | |
Lalit Maganti | e87cc81 | 2019-01-10 15:20:06 +0000 | [diff] [blame] | 501 | const std::deque<uint32_t>& cpus() const { return cpus_; } |
| 502 | |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 503 | const std::deque<UniqueTid>& utids() const { return utids_; } |
| 504 | |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 505 | const std::deque<ArgSetId>& arg_set_ids() const { return arg_set_ids_; } |
| 506 | |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 507 | private: |
| 508 | std::deque<int64_t> timestamps_; |
| 509 | std::deque<StringId> name_ids_; |
Lalit Maganti | e87cc81 | 2019-01-10 15:20:06 +0000 | [diff] [blame] | 510 | std::deque<uint32_t> cpus_; |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 511 | std::deque<UniqueTid> utids_; |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 512 | std::deque<ArgSetId> arg_set_ids_; |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 513 | }; |
| 514 | |
Primiano Tucci | 2c761ef | 2019-01-07 20:20:46 +0000 | [diff] [blame] | 515 | class AndroidLogs { |
| 516 | public: |
| 517 | inline size_t AddLogEvent(int64_t timestamp, |
| 518 | UniqueTid utid, |
| 519 | uint8_t prio, |
| 520 | StringId tag_id, |
| 521 | StringId msg_id) { |
| 522 | timestamps_.emplace_back(timestamp); |
| 523 | utids_.emplace_back(utid); |
| 524 | prios_.emplace_back(prio); |
| 525 | tag_ids_.emplace_back(tag_id); |
| 526 | msg_ids_.emplace_back(msg_id); |
| 527 | return size() - 1; |
| 528 | } |
| 529 | |
| 530 | size_t size() const { return timestamps_.size(); } |
| 531 | |
| 532 | const std::deque<int64_t>& timestamps() const { return timestamps_; } |
| 533 | const std::deque<UniqueTid>& utids() const { return utids_; } |
| 534 | const std::deque<uint8_t>& prios() const { return prios_; } |
| 535 | const std::deque<StringId>& tag_ids() const { return tag_ids_; } |
| 536 | const std::deque<StringId>& msg_ids() const { return msg_ids_; } |
| 537 | |
| 538 | private: |
| 539 | std::deque<int64_t> timestamps_; |
| 540 | std::deque<UniqueTid> utids_; |
| 541 | std::deque<uint8_t> prios_; |
| 542 | std::deque<StringId> tag_ids_; |
| 543 | std::deque<StringId> msg_ids_; |
| 544 | }; |
| 545 | |
Primiano Tucci | 0e38a14 | 2019-01-07 20:51:09 +0000 | [diff] [blame] | 546 | struct Stats { |
| 547 | using IndexMap = std::map<int, int64_t>; |
| 548 | int64_t value = 0; |
| 549 | IndexMap indexed_values; |
| 550 | }; |
| 551 | using StatsMap = std::array<Stats, stats::kNumKeys>; |
| 552 | |
Ryan Savitski | 51413ad | 2019-07-09 14:25:21 +0100 | [diff] [blame] | 553 | class Metadata { |
| 554 | public: |
| 555 | const std::deque<metadata::KeyIDs>& keys() const { return keys_; } |
| 556 | const std::deque<Variadic>& values() const { return values_; } |
| 557 | |
Lalit Maganti | 7449dc8 | 2019-12-30 15:52:35 +0000 | [diff] [blame] | 558 | uint32_t SetScalarMetadata(metadata::KeyIDs key, Variadic value) { |
Ryan Savitski | 51413ad | 2019-07-09 14:25:21 +0100 | [diff] [blame] | 559 | PERFETTO_DCHECK(key < metadata::kNumKeys); |
| 560 | PERFETTO_DCHECK(metadata::kKeyTypes[key] == metadata::kSingle); |
| 561 | PERFETTO_DCHECK(value.type == metadata::kValueTypes[key]); |
| 562 | |
| 563 | // Already set - on release builds, overwrite the previous value. |
| 564 | auto it = scalar_indices.find(key); |
| 565 | if (it != scalar_indices.end()) { |
| 566 | PERFETTO_DFATAL("Setting a scalar metadata entry more than once."); |
| 567 | uint32_t index = static_cast<uint32_t>(it->second); |
| 568 | values_[index] = value; |
Lalit Maganti | 7449dc8 | 2019-12-30 15:52:35 +0000 | [diff] [blame] | 569 | return index; |
Ryan Savitski | 51413ad | 2019-07-09 14:25:21 +0100 | [diff] [blame] | 570 | } |
| 571 | // First time setting this key. |
| 572 | keys_.push_back(key); |
| 573 | values_.push_back(value); |
| 574 | uint32_t index = static_cast<uint32_t>(keys_.size() - 1); |
| 575 | scalar_indices[key] = index; |
Lalit Maganti | 7449dc8 | 2019-12-30 15:52:35 +0000 | [diff] [blame] | 576 | return index; |
Ryan Savitski | 51413ad | 2019-07-09 14:25:21 +0100 | [diff] [blame] | 577 | } |
| 578 | |
Lalit Maganti | 7449dc8 | 2019-12-30 15:52:35 +0000 | [diff] [blame] | 579 | uint32_t AppendMetadata(metadata::KeyIDs key, Variadic value) { |
Ryan Savitski | 51413ad | 2019-07-09 14:25:21 +0100 | [diff] [blame] | 580 | PERFETTO_DCHECK(key < metadata::kNumKeys); |
| 581 | PERFETTO_DCHECK(metadata::kKeyTypes[key] == metadata::kMulti); |
| 582 | PERFETTO_DCHECK(value.type == metadata::kValueTypes[key]); |
| 583 | |
| 584 | keys_.push_back(key); |
| 585 | values_.push_back(value); |
Lalit Maganti | 7449dc8 | 2019-12-30 15:52:35 +0000 | [diff] [blame] | 586 | return static_cast<uint32_t>(keys_.size() - 1); |
Ryan Savitski | 51413ad | 2019-07-09 14:25:21 +0100 | [diff] [blame] | 587 | } |
| 588 | |
Isabelle Taylor | 13a7585 | 2019-11-20 10:29:40 +0000 | [diff] [blame] | 589 | const Variadic& GetScalarMetadata(metadata::KeyIDs key) const { |
| 590 | PERFETTO_DCHECK(scalar_indices.count(key) == 1); |
| 591 | return values_.at(scalar_indices.at(key)); |
| 592 | } |
| 593 | |
| 594 | bool MetadataExists(metadata::KeyIDs key) const { |
| 595 | return scalar_indices.count(key) >= 1; |
| 596 | } |
| 597 | |
Ryan Savitski | 0476ee9 | 2019-07-09 14:29:33 +0100 | [diff] [blame] | 598 | void OverwriteMetadata(uint32_t index, Variadic value) { |
| 599 | PERFETTO_DCHECK(index < values_.size()); |
| 600 | values_[index] = value; |
| 601 | } |
| 602 | |
Ryan Savitski | 51413ad | 2019-07-09 14:25:21 +0100 | [diff] [blame] | 603 | private: |
| 604 | std::deque<metadata::KeyIDs> keys_; |
| 605 | std::deque<Variadic> values_; |
| 606 | // Extraneous state to track locations of entries that should have at most |
| 607 | // one row. Used only to maintain uniqueness during insertions. |
| 608 | std::map<metadata::KeyIDs, uint32_t> scalar_indices; |
| 609 | }; |
Mikhail Khokhlov | e466c00 | 2019-05-23 13:33:33 +0100 | [diff] [blame] | 610 | |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 611 | UniqueTid AddEmptyThread(uint32_t tid) { |
| 612 | unique_threads_.emplace_back(tid); |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 613 | return static_cast<UniqueTid>(unique_threads_.size() - 1); |
| 614 | } |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 615 | |
Primiano Tucci | b75dcee | 2018-08-08 12:21:36 +0100 | [diff] [blame] | 616 | UniquePid AddEmptyProcess(uint32_t pid) { |
| 617 | unique_processes_.emplace_back(pid); |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 618 | return static_cast<UniquePid>(unique_processes_.size() - 1); |
| 619 | } |
Isabelle Taylor | 3dd366c | 2018-06-22 16:21:41 +0100 | [diff] [blame] | 620 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 621 | // Return an unqiue identifier for the contents of each string. |
| 622 | // The string is copied internally and can be destroyed after this called. |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 623 | // Virtual for testing. |
Lalit Maganti | 5c45431 | 2019-04-08 12:11:17 +0100 | [diff] [blame] | 624 | virtual StringId InternString(base::StringView str) { |
| 625 | return string_pool_.InternString(str); |
| 626 | } |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 627 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 628 | Process* GetMutableProcess(UniquePid upid) { |
Lalit Maganti | 676658b | 2018-11-20 18:24:31 +0000 | [diff] [blame] | 629 | PERFETTO_DCHECK(upid < unique_processes_.size()); |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 630 | return &unique_processes_[upid]; |
| 631 | } |
Isabelle Taylor | 3dd366c | 2018-06-22 16:21:41 +0100 | [diff] [blame] | 632 | |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 633 | Thread* GetMutableThread(UniqueTid utid) { |
Florian Mayer | a1aaec2 | 2018-09-19 17:02:26 +0100 | [diff] [blame] | 634 | PERFETTO_DCHECK(utid < unique_threads_.size()); |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 635 | return &unique_threads_[utid]; |
| 636 | } |
Isabelle Taylor | 3dd366c | 2018-06-22 16:21:41 +0100 | [diff] [blame] | 637 | |
Primiano Tucci | 0e38a14 | 2019-01-07 20:51:09 +0000 | [diff] [blame] | 638 | // Example usage: SetStats(stats::android_log_num_failed, 42); |
| 639 | void SetStats(size_t key, int64_t value) { |
| 640 | PERFETTO_DCHECK(key < stats::kNumKeys); |
| 641 | PERFETTO_DCHECK(stats::kTypes[key] == stats::kSingle); |
| 642 | stats_[key].value = value; |
| 643 | } |
| 644 | |
| 645 | // Example usage: IncrementStats(stats::android_log_num_failed, -1); |
| 646 | void IncrementStats(size_t key, int64_t increment = 1) { |
| 647 | PERFETTO_DCHECK(key < stats::kNumKeys); |
| 648 | PERFETTO_DCHECK(stats::kTypes[key] == stats::kSingle); |
| 649 | stats_[key].value += increment; |
| 650 | } |
| 651 | |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 652 | // Example usage: IncrementIndexedStats(stats::cpu_failure, 1); |
| 653 | void IncrementIndexedStats(size_t key, int index, int64_t increment = 1) { |
| 654 | PERFETTO_DCHECK(key < stats::kNumKeys); |
| 655 | PERFETTO_DCHECK(stats::kTypes[key] == stats::kIndexed); |
| 656 | stats_[key].indexed_values[index] += increment; |
| 657 | } |
| 658 | |
Primiano Tucci | 0e38a14 | 2019-01-07 20:51:09 +0000 | [diff] [blame] | 659 | // Example usage: SetIndexedStats(stats::cpu_failure, 1, 42); |
| 660 | void SetIndexedStats(size_t key, int index, int64_t value) { |
| 661 | PERFETTO_DCHECK(key < stats::kNumKeys); |
| 662 | PERFETTO_DCHECK(stats::kTypes[key] == stats::kIndexed); |
| 663 | stats_[key].indexed_values[index] = value; |
| 664 | } |
| 665 | |
Mikhail Khokhlov | e466c00 | 2019-05-23 13:33:33 +0100 | [diff] [blame] | 666 | // Example usage: |
| 667 | // SetMetadata(metadata::benchmark_name, |
| 668 | // Variadic::String(storage->InternString("foo")); |
Lalit Maganti | 7449dc8 | 2019-12-30 15:52:35 +0000 | [diff] [blame] | 669 | // Returns the row of the new entry. |
Mikhail Khokhlov | b1fe42a | 2019-05-23 13:58:05 +0100 | [diff] [blame] | 670 | // Virtual for testing. |
Lalit Maganti | 7449dc8 | 2019-12-30 15:52:35 +0000 | [diff] [blame] | 671 | virtual uint32_t SetMetadata(metadata::KeyIDs key, Variadic value) { |
Ryan Savitski | 51413ad | 2019-07-09 14:25:21 +0100 | [diff] [blame] | 672 | return metadata_.SetScalarMetadata(key, value); |
Mikhail Khokhlov | e466c00 | 2019-05-23 13:33:33 +0100 | [diff] [blame] | 673 | } |
| 674 | |
| 675 | // Example usage: |
| 676 | // AppendMetadata(metadata::benchmark_story_tags, |
| 677 | // Variadic::String(storage->InternString("bar")); |
Lalit Maganti | 7449dc8 | 2019-12-30 15:52:35 +0000 | [diff] [blame] | 678 | // Returns the row of the new entry. |
Mikhail Khokhlov | b1fe42a | 2019-05-23 13:58:05 +0100 | [diff] [blame] | 679 | // Virtual for testing. |
Lalit Maganti | 7449dc8 | 2019-12-30 15:52:35 +0000 | [diff] [blame] | 680 | virtual uint32_t AppendMetadata(metadata::KeyIDs key, Variadic value) { |
Ryan Savitski | 51413ad | 2019-07-09 14:25:21 +0100 | [diff] [blame] | 681 | return metadata_.AppendMetadata(key, value); |
Mikhail Khokhlov | e466c00 | 2019-05-23 13:33:33 +0100 | [diff] [blame] | 682 | } |
| 683 | |
Eric Seckler | 77b5278 | 2019-05-02 15:18:57 +0100 | [diff] [blame] | 684 | class ScopedStatsTracer { |
| 685 | public: |
| 686 | ScopedStatsTracer(TraceStorage* storage, size_t key) |
| 687 | : storage_(storage), key_(key), start_ns_(base::GetWallTimeNs()) {} |
| 688 | |
| 689 | ~ScopedStatsTracer() { |
| 690 | if (!storage_) |
| 691 | return; |
| 692 | auto delta_ns = base::GetWallTimeNs() - start_ns_; |
| 693 | storage_->IncrementStats(key_, delta_ns.count()); |
| 694 | } |
| 695 | |
| 696 | ScopedStatsTracer(ScopedStatsTracer&& other) noexcept { MoveImpl(&other); } |
| 697 | |
| 698 | ScopedStatsTracer& operator=(ScopedStatsTracer&& other) { |
| 699 | MoveImpl(&other); |
| 700 | return *this; |
| 701 | } |
| 702 | |
| 703 | private: |
| 704 | ScopedStatsTracer(const ScopedStatsTracer&) = delete; |
| 705 | ScopedStatsTracer& operator=(const ScopedStatsTracer&) = delete; |
| 706 | |
| 707 | void MoveImpl(ScopedStatsTracer* other) { |
| 708 | storage_ = other->storage_; |
| 709 | key_ = other->key_; |
| 710 | start_ns_ = other->start_ns_; |
| 711 | other->storage_ = nullptr; |
| 712 | } |
| 713 | |
| 714 | TraceStorage* storage_; |
| 715 | size_t key_; |
| 716 | base::TimeNanos start_ns_; |
| 717 | }; |
| 718 | |
| 719 | ScopedStatsTracer TraceExecutionTimeIntoStats(size_t key) { |
| 720 | return ScopedStatsTracer(this, key); |
| 721 | } |
| 722 | |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 723 | // Reading methods. |
Eric Seckler | c93823e | 2019-06-03 16:49:19 +0100 | [diff] [blame] | 724 | // Virtual for testing. |
| 725 | virtual NullTermStringView GetString(StringId id) const { |
Lalit Maganti | 5c45431 | 2019-04-08 12:11:17 +0100 | [diff] [blame] | 726 | return string_pool_.Get(id); |
Isabelle Taylor | a0a2297 | 2018-08-03 12:06:12 +0100 | [diff] [blame] | 727 | } |
| 728 | |
Lalit Maganti | e9d4053 | 2018-06-29 13:15:06 +0100 | [diff] [blame] | 729 | const Process& GetProcess(UniquePid upid) const { |
Lalit Maganti | 676658b | 2018-11-20 18:24:31 +0000 | [diff] [blame] | 730 | PERFETTO_DCHECK(upid < unique_processes_.size()); |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 731 | return unique_processes_[upid]; |
| 732 | } |
| 733 | |
Eric Seckler | b32cacf | 2019-09-27 16:51:19 +0100 | [diff] [blame] | 734 | // Virtual for testing. |
| 735 | virtual const Thread& GetThread(UniqueTid utid) const { |
Lalit Maganti | 1f64cfa | 2018-09-18 13:20:02 +0100 | [diff] [blame] | 736 | // Allow utid == 0 for idle thread retrieval. |
Florian Mayer | a1aaec2 | 2018-09-19 17:02:26 +0100 | [diff] [blame] | 737 | PERFETTO_DCHECK(utid < unique_threads_.size()); |
Isabelle Taylor | 68e4219 | 2018-06-19 16:19:31 +0100 | [diff] [blame] | 738 | return unique_threads_[utid]; |
| 739 | } |
| 740 | |
Lalit Maganti | ac68e9c | 2019-09-09 18:12:15 +0100 | [diff] [blame] | 741 | const tables::TrackTable& track_table() const { return track_table_; } |
| 742 | tables::TrackTable* mutable_track_table() { return &track_table_; } |
Lalit Maganti | d11d3e0 | 2019-07-26 12:32:09 +0530 | [diff] [blame] | 743 | |
Lalit Maganti | 53bdbb2 | 2019-09-25 11:11:18 +0100 | [diff] [blame] | 744 | const tables::ProcessTrackTable& process_track_table() const { |
| 745 | return process_track_table_; |
Lalit Maganti | 4ea78d9 | 2019-09-20 20:20:41 +0100 | [diff] [blame] | 746 | } |
Lalit Maganti | 53bdbb2 | 2019-09-25 11:11:18 +0100 | [diff] [blame] | 747 | tables::ProcessTrackTable* mutable_process_track_table() { |
| 748 | return &process_track_table_; |
Lalit Maganti | 4ea78d9 | 2019-09-20 20:20:41 +0100 | [diff] [blame] | 749 | } |
Eric Seckler | 5703ede | 2019-07-10 10:13:02 +0100 | [diff] [blame] | 750 | |
Lalit Maganti | fedc15b | 2019-09-26 18:37:52 +0100 | [diff] [blame] | 751 | const tables::ThreadTrackTable& thread_track_table() const { |
| 752 | return thread_track_table_; |
| 753 | } |
| 754 | tables::ThreadTrackTable* mutable_thread_track_table() { |
| 755 | return &thread_track_table_; |
| 756 | } |
| 757 | |
Lalit Maganti | 809b2f9 | 2019-11-07 13:27:26 +0000 | [diff] [blame] | 758 | const tables::CounterTrackTable& counter_track_table() const { |
| 759 | return counter_track_table_; |
| 760 | } |
| 761 | tables::CounterTrackTable* mutable_counter_track_table() { |
| 762 | return &counter_track_table_; |
| 763 | } |
| 764 | |
| 765 | const tables::ThreadCounterTrackTable& thread_counter_track_table() const { |
| 766 | return thread_counter_track_table_; |
| 767 | } |
| 768 | tables::ThreadCounterTrackTable* mutable_thread_counter_track_table() { |
| 769 | return &thread_counter_track_table_; |
| 770 | } |
| 771 | |
| 772 | const tables::ProcessCounterTrackTable& process_counter_track_table() const { |
| 773 | return process_counter_track_table_; |
| 774 | } |
| 775 | tables::ProcessCounterTrackTable* mutable_process_counter_track_table() { |
| 776 | return &process_counter_track_table_; |
| 777 | } |
| 778 | |
| 779 | const tables::CpuCounterTrackTable& cpu_counter_track_table() const { |
| 780 | return cpu_counter_track_table_; |
| 781 | } |
| 782 | tables::CpuCounterTrackTable* mutable_cpu_counter_track_table() { |
| 783 | return &cpu_counter_track_table_; |
| 784 | } |
| 785 | |
| 786 | const tables::IrqCounterTrackTable& irq_counter_track_table() const { |
| 787 | return irq_counter_track_table_; |
| 788 | } |
| 789 | tables::IrqCounterTrackTable* mutable_irq_counter_track_table() { |
| 790 | return &irq_counter_track_table_; |
| 791 | } |
| 792 | |
| 793 | const tables::SoftirqCounterTrackTable& softirq_counter_track_table() const { |
| 794 | return softirq_counter_track_table_; |
| 795 | } |
| 796 | tables::SoftirqCounterTrackTable* mutable_softirq_counter_track_table() { |
| 797 | return &softirq_counter_track_table_; |
| 798 | } |
| 799 | |
| 800 | const tables::GpuCounterTrackTable& gpu_counter_track_table() const { |
| 801 | return gpu_counter_track_table_; |
| 802 | } |
| 803 | tables::GpuCounterTrackTable* mutable_gpu_counter_track_table() { |
| 804 | return &gpu_counter_track_table_; |
| 805 | } |
| 806 | |
Lalit Maganti | ff69c11 | 2018-09-24 12:07:47 +0100 | [diff] [blame] | 807 | const Slices& slices() const { return slices_; } |
Lalit Maganti | fde2904 | 2018-10-04 13:28:52 +0100 | [diff] [blame] | 808 | Slices* mutable_slices() { return &slices_; } |
| 809 | |
Lalit Maganti | 1308e3f | 2019-12-09 20:24:20 +0000 | [diff] [blame] | 810 | const tables::SliceTable& slice_table() const { return slice_table_; } |
| 811 | tables::SliceTable* mutable_slice_table() { return &slice_table_; } |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 812 | |
Eric Seckler | d3b89d5 | 2019-07-10 15:36:29 +0100 | [diff] [blame] | 813 | const ThreadSlices& thread_slices() const { return thread_slices_; } |
| 814 | ThreadSlices* mutable_thread_slices() { return &thread_slices_; } |
| 815 | |
Eric Seckler | c3430c6 | 2019-07-22 10:49:58 +0100 | [diff] [blame] | 816 | const VirtualTrackSlices& virtual_track_slices() const { |
| 817 | return virtual_track_slices_; |
| 818 | } |
| 819 | VirtualTrackSlices* mutable_virtual_track_slices() { |
| 820 | return &virtual_track_slices_; |
| 821 | } |
| 822 | |
Lalit Maganti | 20539c2 | 2019-09-04 12:36:10 +0100 | [diff] [blame] | 823 | const tables::GpuSliceTable& gpu_slice_table() const { |
| 824 | return gpu_slice_table_; |
| 825 | } |
| 826 | tables::GpuSliceTable* mutable_gpu_slice_table() { return &gpu_slice_table_; } |
Mikael Pessa | 7160ccc | 2019-07-25 11:19:26 -0700 | [diff] [blame] | 827 | |
Lalit Maganti | 4b3b3ad | 2019-12-04 19:27:35 +0000 | [diff] [blame] | 828 | const tables::CounterTable& counter_table() const { return counter_table_; } |
| 829 | tables::CounterTable* mutable_counter_table() { return &counter_table_; } |
Isabelle Taylor | 14674d4 | 2018-09-07 11:33:11 +0100 | [diff] [blame] | 830 | |
Primiano Tucci | 5cb84f8 | 2018-10-31 21:46:36 -0700 | [diff] [blame] | 831 | const SqlStats& sql_stats() const { return sql_stats_; } |
| 832 | SqlStats* mutable_sql_stats() { return &sql_stats_; } |
| 833 | |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 834 | const Instants& instants() const { return instants_; } |
| 835 | Instants* mutable_instants() { return &instants_; } |
| 836 | |
Primiano Tucci | 2c761ef | 2019-01-07 20:20:46 +0000 | [diff] [blame] | 837 | const AndroidLogs& android_logs() const { return android_log_; } |
| 838 | AndroidLogs* mutable_android_log() { return &android_log_; } |
| 839 | |
Primiano Tucci | 0e38a14 | 2019-01-07 20:51:09 +0000 | [diff] [blame] | 840 | const StatsMap& stats() const { return stats_; } |
Lalit Maganti | 05e8c13 | 2018-11-09 18:16:12 +0000 | [diff] [blame] | 841 | |
Ryan Savitski | 51413ad | 2019-07-09 14:25:21 +0100 | [diff] [blame] | 842 | const Metadata& metadata() const { return metadata_; } |
Ryan Savitski | 0476ee9 | 2019-07-09 14:29:33 +0100 | [diff] [blame] | 843 | Metadata* mutable_metadata() { return &metadata_; } |
Mikhail Khokhlov | e466c00 | 2019-05-23 13:33:33 +0100 | [diff] [blame] | 844 | |
Lalit Maganti | 6e9c55e | 2018-11-29 12:00:39 +0000 | [diff] [blame] | 845 | const Args& args() const { return args_; } |
| 846 | Args* mutable_args() { return &args_; } |
| 847 | |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 848 | const RawEvents& raw_events() const { return raw_events_; } |
| 849 | RawEvents* mutable_raw_events() { return &raw_events_; } |
| 850 | |
Lalit Maganti | 45980c9 | 2019-12-20 13:17:44 +0000 | [diff] [blame] | 851 | const tables::StackProfileMappingTable& stack_profile_mapping_table() const { |
| 852 | return stack_profile_mapping_table_; |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 853 | } |
Lalit Maganti | 45980c9 | 2019-12-20 13:17:44 +0000 | [diff] [blame] | 854 | tables::StackProfileMappingTable* mutable_stack_profile_mapping_table() { |
| 855 | return &stack_profile_mapping_table_; |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 856 | } |
| 857 | |
Lalit Maganti | 0a29f6f | 2020-01-06 12:01:14 +0000 | [diff] [blame] | 858 | const tables::StackProfileFrameTable& stack_profile_frame_table() const { |
| 859 | return stack_profile_frame_table_; |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 860 | } |
Lalit Maganti | 0a29f6f | 2020-01-06 12:01:14 +0000 | [diff] [blame] | 861 | tables::StackProfileFrameTable* mutable_stack_profile_frame_table() { |
| 862 | return &stack_profile_frame_table_; |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 863 | } |
| 864 | |
Lalit Maganti | aa0ff5b | 2019-10-25 10:35:48 +0100 | [diff] [blame] | 865 | const tables::StackProfileCallsiteTable& stack_profile_callsite_table() |
| 866 | const { |
| 867 | return stack_profile_callsite_table_; |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 868 | } |
Lalit Maganti | aa0ff5b | 2019-10-25 10:35:48 +0100 | [diff] [blame] | 869 | tables::StackProfileCallsiteTable* mutable_stack_profile_callsite_table() { |
| 870 | return &stack_profile_callsite_table_; |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 871 | } |
| 872 | |
Lalit Maganti | a5ffb20 | 2019-12-17 18:10:52 +0000 | [diff] [blame] | 873 | const tables::HeapProfileAllocationTable& heap_profile_allocation_table() |
| 874 | const { |
| 875 | return heap_profile_allocation_table_; |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 876 | } |
Lalit Maganti | a5ffb20 | 2019-12-17 18:10:52 +0000 | [diff] [blame] | 877 | tables::HeapProfileAllocationTable* mutable_heap_profile_allocation_table() { |
| 878 | return &heap_profile_allocation_table_; |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 879 | } |
Lalit Maganti | 0fd14ef | 2019-12-18 18:18:44 +0000 | [diff] [blame] | 880 | const tables::CpuProfileStackSampleTable& cpu_profile_stack_sample_table() |
| 881 | const { |
| 882 | return cpu_profile_stack_sample_table_; |
Oystein Eftevaag | 7f64c10 | 2019-08-29 10:27:31 -0700 | [diff] [blame] | 883 | } |
Lalit Maganti | 0fd14ef | 2019-12-18 18:18:44 +0000 | [diff] [blame] | 884 | tables::CpuProfileStackSampleTable* mutable_cpu_profile_stack_sample_table() { |
| 885 | return &cpu_profile_stack_sample_table_; |
Oystein Eftevaag | 7f64c10 | 2019-08-29 10:27:31 -0700 | [diff] [blame] | 886 | } |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 887 | |
Ioannis Ilkos | e0b47f5 | 2019-09-18 11:14:57 +0100 | [diff] [blame] | 888 | const tables::SymbolTable& symbol_table() const { return symbol_table_; } |
| 889 | |
| 890 | tables::SymbolTable* mutable_symbol_table() { return &symbol_table_; } |
| 891 | |
Florian Mayer | 25e013e | 2019-10-01 14:06:15 +0100 | [diff] [blame] | 892 | const tables::HeapGraphObjectTable& heap_graph_object_table() const { |
| 893 | return heap_graph_object_table_; |
| 894 | } |
| 895 | |
| 896 | tables::HeapGraphObjectTable* mutable_heap_graph_object_table() { |
| 897 | return &heap_graph_object_table_; |
| 898 | } |
| 899 | |
Florian Mayer | 9c01d16 | 2019-10-09 17:55:32 +0100 | [diff] [blame] | 900 | const tables::HeapGraphReferenceTable& heap_graph_reference_table() const { |
| 901 | return heap_graph_reference_table_; |
| 902 | } |
| 903 | |
| 904 | tables::HeapGraphReferenceTable* mutable_heap_graph_reference_table() { |
| 905 | return &heap_graph_reference_table_; |
| 906 | } |
| 907 | |
Lalit Maganti | 20539c2 | 2019-09-04 12:36:10 +0100 | [diff] [blame] | 908 | const tables::GpuTrackTable& gpu_track_table() const { |
| 909 | return gpu_track_table_; |
| 910 | } |
| 911 | tables::GpuTrackTable* mutable_gpu_track_table() { return &gpu_track_table_; } |
Mikael Pessa | 7160ccc | 2019-07-25 11:19:26 -0700 | [diff] [blame] | 912 | |
Mohammad Reza Zakerinasab | b06d185 | 2019-09-11 14:41:36 -0400 | [diff] [blame] | 913 | const tables::VulkanMemoryAllocationsTable& vulkan_memory_allocations_table() |
| 914 | const { |
| 915 | return vulkan_memory_allocations_table_; |
| 916 | } |
| 917 | |
| 918 | tables::VulkanMemoryAllocationsTable* |
| 919 | mutable_vulkan_memory_allocations_table() { |
| 920 | return &vulkan_memory_allocations_table_; |
| 921 | } |
| 922 | |
Lalit Maganti | 5c45431 | 2019-04-08 12:11:17 +0100 | [diff] [blame] | 923 | const StringPool& string_pool() const { return string_pool_; } |
Lalit Maganti | acda68b | 2018-10-29 15:23:25 +0000 | [diff] [blame] | 924 | |
Hector Dearman | 5145e50 | 2019-09-18 16:52:24 +0100 | [diff] [blame] | 925 | // |unique_processes_| always contains at least 1 element because the 0th ID |
Isabelle Taylor | e7003fb | 2018-07-17 11:39:01 +0100 | [diff] [blame] | 926 | // is reserved to indicate an invalid process. |
Lalit Maganti | 9c6395b | 2019-01-17 00:25:09 +0000 | [diff] [blame] | 927 | size_t process_count() const { return unique_processes_.size(); } |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 928 | |
Hector Dearman | 5145e50 | 2019-09-18 16:52:24 +0100 | [diff] [blame] | 929 | // |unique_threads_| always contains at least 1 element because the 0th ID |
Isabelle Taylor | e7003fb | 2018-07-17 11:39:01 +0100 | [diff] [blame] | 930 | // is reserved to indicate an invalid thread. |
Lalit Maganti | 9c6395b | 2019-01-17 00:25:09 +0000 | [diff] [blame] | 931 | size_t thread_count() const { return unique_threads_.size(); } |
Isabelle Taylor | e7003fb | 2018-07-17 11:39:01 +0100 | [diff] [blame] | 932 | |
Hector Dearman | 1232336 | 2018-08-09 16:09:28 +0100 | [diff] [blame] | 933 | // Number of interned strings in the pool. Includes the empty string w/ ID=0. |
| 934 | size_t string_count() const { return string_pool_.size(); } |
| 935 | |
Ioannis Ilkos | b8b1110 | 2019-01-29 17:56:55 +0000 | [diff] [blame] | 936 | // Start / end ts (in nanoseconds) across the parsed trace events. |
| 937 | // Returns (0, 0) if the trace is empty. |
| 938 | std::pair<int64_t, int64_t> GetTraceTimestampBoundsNs() const; |
| 939 | |
Lalit Maganti | 45980c9 | 2019-12-20 13:17:44 +0000 | [diff] [blame] | 940 | // TODO(lalitm): remove this when we have a better home. |
| 941 | std::vector<int64_t> FindMappingRow(StringId name, StringId build_id) const { |
| 942 | auto it = stack_profile_mapping_index_.find(std::make_pair(name, build_id)); |
| 943 | if (it == stack_profile_mapping_index_.end()) |
| 944 | return {}; |
| 945 | return it->second; |
| 946 | } |
| 947 | |
| 948 | // TODO(lalitm): remove this when we have a better home. |
| 949 | void InsertMappingRow(StringId name, StringId build_id, uint32_t row) { |
| 950 | auto pair = std::make_pair(name, build_id); |
| 951 | stack_profile_mapping_index_[pair].emplace_back(row); |
| 952 | } |
| 953 | |
Lalit Maganti | 0a29f6f | 2020-01-06 12:01:14 +0000 | [diff] [blame] | 954 | // TODO(lalitm): remove this when we have a better home. |
| 955 | std::vector<int64_t> FindFrameRow(size_t mapping_row, uint64_t rel_pc) const { |
| 956 | auto it = |
| 957 | stack_profile_frame_index_.find(std::make_pair(mapping_row, rel_pc)); |
| 958 | if (it == stack_profile_frame_index_.end()) |
| 959 | return {}; |
| 960 | return it->second; |
| 961 | } |
| 962 | |
| 963 | // TODO(lalitm): remove this when we have a better home. |
| 964 | void InsertFrameRow(size_t mapping_row, uint64_t rel_pc, uint32_t row) { |
| 965 | auto pair = std::make_pair(mapping_row, rel_pc); |
| 966 | stack_profile_frame_index_[pair].emplace_back(row); |
| 967 | } |
| 968 | |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 969 | private: |
Primiano Tucci | 2da5d2e | 2018-08-10 14:23:31 +0100 | [diff] [blame] | 970 | using StringHash = uint64_t; |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 971 | |
Lalit Maganti | 5c45431 | 2019-04-08 12:11:17 +0100 | [diff] [blame] | 972 | TraceStorage(const TraceStorage&) = delete; |
| 973 | TraceStorage& operator=(const TraceStorage&) = delete; |
| 974 | |
Lalit Maganti | 20539c2 | 2019-09-04 12:36:10 +0100 | [diff] [blame] | 975 | TraceStorage(TraceStorage&&) = delete; |
| 976 | TraceStorage& operator=(TraceStorage&&) = delete; |
| 977 | |
Lalit Maganti | 45980c9 | 2019-12-20 13:17:44 +0000 | [diff] [blame] | 978 | // TODO(lalitm): remove this when we find a better home for this. |
| 979 | using MappingKey = std::pair<StringId /* name */, StringId /* build id */>; |
| 980 | std::map<MappingKey, std::vector<int64_t>> stack_profile_mapping_index_; |
| 981 | |
Lalit Maganti | 0a29f6f | 2020-01-06 12:01:14 +0000 | [diff] [blame] | 982 | // TODO(lalitm): remove this when we find a better home for this. |
| 983 | using FrameKey = std::pair<size_t /* mapping row */, uint64_t /* rel_pc */>; |
| 984 | std::map<MappingKey, std::vector<int64_t>> stack_profile_frame_index_; |
| 985 | |
Lalit Maganti | 20539c2 | 2019-09-04 12:36:10 +0100 | [diff] [blame] | 986 | // One entry for each unique string in the trace. |
| 987 | StringPool string_pool_; |
Lalit Maganti | 4fa7c6c | 2019-02-06 15:06:36 +0000 | [diff] [blame] | 988 | |
Lalit Maganti | 05e8c13 | 2018-11-09 18:16:12 +0000 | [diff] [blame] | 989 | // Stats about parsing the trace. |
Primiano Tucci | 0e38a14 | 2019-01-07 20:51:09 +0000 | [diff] [blame] | 990 | StatsMap stats_{}; |
Lalit Maganti | 35622b7 | 2018-06-06 12:03:11 +0100 | [diff] [blame] | 991 | |
Ryan Savitski | 51413ad | 2019-07-09 14:25:21 +0100 | [diff] [blame] | 992 | // Extra data extracted from the trace. Includes: |
| 993 | // * metadata from chrome and benchmarking infrastructure |
| 994 | // * descriptions of android packages |
| 995 | Metadata metadata_{}; |
Mikhail Khokhlov | e466c00 | 2019-05-23 13:33:33 +0100 | [diff] [blame] | 996 | |
Lalit Maganti | d11d3e0 | 2019-07-26 12:32:09 +0530 | [diff] [blame] | 997 | // Metadata for tracks. |
Lalit Maganti | ac68e9c | 2019-09-09 18:12:15 +0100 | [diff] [blame] | 998 | tables::TrackTable track_table_{&string_pool_, nullptr}; |
Lalit Maganti | 4ea78d9 | 2019-09-20 20:20:41 +0100 | [diff] [blame] | 999 | tables::GpuTrackTable gpu_track_table_{&string_pool_, &track_table_}; |
Lalit Maganti | 53bdbb2 | 2019-09-25 11:11:18 +0100 | [diff] [blame] | 1000 | tables::ProcessTrackTable process_track_table_{&string_pool_, &track_table_}; |
Lalit Maganti | fedc15b | 2019-09-26 18:37:52 +0100 | [diff] [blame] | 1001 | tables::ThreadTrackTable thread_track_table_{&string_pool_, &track_table_}; |
Eric Seckler | 5703ede | 2019-07-10 10:13:02 +0100 | [diff] [blame] | 1002 | |
Lalit Maganti | 809b2f9 | 2019-11-07 13:27:26 +0000 | [diff] [blame] | 1003 | // Track tables for counter events. |
| 1004 | tables::CounterTrackTable counter_track_table_{&string_pool_, &track_table_}; |
| 1005 | tables::ThreadCounterTrackTable thread_counter_track_table_{ |
| 1006 | &string_pool_, &counter_track_table_}; |
| 1007 | tables::ProcessCounterTrackTable process_counter_track_table_{ |
| 1008 | &string_pool_, &counter_track_table_}; |
| 1009 | tables::CpuCounterTrackTable cpu_counter_track_table_{&string_pool_, |
| 1010 | &counter_track_table_}; |
| 1011 | tables::IrqCounterTrackTable irq_counter_track_table_{&string_pool_, |
| 1012 | &counter_track_table_}; |
| 1013 | tables::SoftirqCounterTrackTable softirq_counter_track_table_{ |
| 1014 | &string_pool_, &counter_track_table_}; |
| 1015 | tables::GpuCounterTrackTable gpu_counter_track_table_{&string_pool_, |
| 1016 | &counter_track_table_}; |
| 1017 | |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 1018 | // One entry for each CPU in the trace. |
Lalit Maganti | ff69c11 | 2018-09-24 12:07:47 +0100 | [diff] [blame] | 1019 | Slices slices_; |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 1020 | |
Lalit Maganti | 6e9c55e | 2018-11-29 12:00:39 +0000 | [diff] [blame] | 1021 | // Args for all other tables. |
| 1022 | Args args_; |
| 1023 | |
Isabelle Taylor | 47328cf | 2018-06-12 14:33:59 +0100 | [diff] [blame] | 1024 | // One entry for each UniquePid, with UniquePid as the index. |
Ioannis Ilkos | 9c03cbd | 2019-03-12 18:30:43 +0000 | [diff] [blame] | 1025 | // Never hold on to pointers to Process, as vector resize will |
| 1026 | // invalidate them. |
| 1027 | std::vector<Process> unique_processes_; |
Isabelle Taylor | 68e4219 | 2018-06-19 16:19:31 +0100 | [diff] [blame] | 1028 | |
Isabelle Taylor | 68e4219 | 2018-06-19 16:19:31 +0100 | [diff] [blame] | 1029 | // One entry for each UniqueTid, with UniqueTid as the index. |
Isabelle Taylor | 3dd366c | 2018-06-22 16:21:41 +0100 | [diff] [blame] | 1030 | std::deque<Thread> unique_threads_; |
Primiano Tucci | 0d72a31 | 2018-08-07 14:42:45 +0100 | [diff] [blame] | 1031 | |
| 1032 | // Slices coming from userspace events (e.g. Chromium TRACE_EVENT macros). |
Lalit Maganti | 1308e3f | 2019-12-09 20:24:20 +0000 | [diff] [blame] | 1033 | tables::SliceTable slice_table_{&string_pool_, nullptr}; |
Isabelle Taylor | 15314ea | 2018-09-19 11:35:19 +0100 | [diff] [blame] | 1034 | |
Eric Seckler | d3b89d5 | 2019-07-10 15:36:29 +0100 | [diff] [blame] | 1035 | // Additional attributes for threads slices (sub-type of NestableSlices). |
| 1036 | ThreadSlices thread_slices_; |
| 1037 | |
Eric Seckler | c3430c6 | 2019-07-22 10:49:58 +0100 | [diff] [blame] | 1038 | // Additional attributes for virtual track slices (sub-type of |
| 1039 | // NestableSlices). |
| 1040 | VirtualTrackSlices virtual_track_slices_; |
| 1041 | |
Mikael Pessa | 803090c | 2019-08-23 16:03:34 -0700 | [diff] [blame] | 1042 | // Additional attributes for gpu track slices (sub-type of |
| 1043 | // NestableSlices). |
Lalit Maganti | 20539c2 | 2019-09-04 12:36:10 +0100 | [diff] [blame] | 1044 | tables::GpuSliceTable gpu_slice_table_{&string_pool_, nullptr}; |
Mikael Pessa | 803090c | 2019-08-23 16:03:34 -0700 | [diff] [blame] | 1045 | |
Lalit Maganti | 8320e6d | 2019-03-14 18:49:33 +0000 | [diff] [blame] | 1046 | // The values from the Counter events from the trace. This includes CPU |
| 1047 | // frequency events as well systrace trace_marker counter events. |
Lalit Maganti | 4b3b3ad | 2019-12-04 19:27:35 +0000 | [diff] [blame] | 1048 | tables::CounterTable counter_table_{&string_pool_, nullptr}; |
Primiano Tucci | 5cb84f8 | 2018-10-31 21:46:36 -0700 | [diff] [blame] | 1049 | |
| 1050 | SqlStats sql_stats_; |
Lalit Maganti | 6e9c55e | 2018-11-29 12:00:39 +0000 | [diff] [blame] | 1051 | |
Isabelle Taylor | c8c1120 | 2018-11-05 11:36:22 +0000 | [diff] [blame] | 1052 | // These are instantaneous events in the trace. They have no duration |
| 1053 | // and do not have a value that make sense to track over time. |
| 1054 | // e.g. signal events |
| 1055 | Instants instants_; |
Lalit Maganti | 1d915a6 | 2019-01-07 12:10:42 +0000 | [diff] [blame] | 1056 | |
| 1057 | // Raw events are every ftrace event in the trace. The raw event includes |
| 1058 | // the timestamp and the pid. The args for the raw event will be in the |
| 1059 | // args table. This table can be used to generate a text version of the |
| 1060 | // trace. |
| 1061 | RawEvents raw_events_; |
Primiano Tucci | 2c761ef | 2019-01-07 20:20:46 +0000 | [diff] [blame] | 1062 | AndroidLogs android_log_; |
Florian Mayer | 438b5ab | 2019-05-02 11:18:06 +0100 | [diff] [blame] | 1063 | |
Lalit Maganti | 45980c9 | 2019-12-20 13:17:44 +0000 | [diff] [blame] | 1064 | tables::StackProfileMappingTable stack_profile_mapping_table_{&string_pool_, |
| 1065 | nullptr}; |
Lalit Maganti | 0a29f6f | 2020-01-06 12:01:14 +0000 | [diff] [blame] | 1066 | tables::StackProfileFrameTable stack_profile_frame_table_{&string_pool_, |
| 1067 | nullptr}; |
Lalit Maganti | aa0ff5b | 2019-10-25 10:35:48 +0100 | [diff] [blame] | 1068 | tables::StackProfileCallsiteTable stack_profile_callsite_table_{&string_pool_, |
| 1069 | nullptr}; |
Lalit Maganti | a5ffb20 | 2019-12-17 18:10:52 +0000 | [diff] [blame] | 1070 | tables::HeapProfileAllocationTable heap_profile_allocation_table_{ |
| 1071 | &string_pool_, nullptr}; |
Lalit Maganti | 0fd14ef | 2019-12-18 18:18:44 +0000 | [diff] [blame] | 1072 | tables::CpuProfileStackSampleTable cpu_profile_stack_sample_table_{ |
| 1073 | &string_pool_, nullptr}; |
Ioannis Ilkos | e0b47f5 | 2019-09-18 11:14:57 +0100 | [diff] [blame] | 1074 | |
| 1075 | // Symbol tables (mappings from frames to symbol names) |
| 1076 | tables::SymbolTable symbol_table_{&string_pool_, nullptr}; |
Florian Mayer | 25e013e | 2019-10-01 14:06:15 +0100 | [diff] [blame] | 1077 | tables::HeapGraphObjectTable heap_graph_object_table_{&string_pool_, nullptr}; |
Florian Mayer | 9c01d16 | 2019-10-09 17:55:32 +0100 | [diff] [blame] | 1078 | tables::HeapGraphReferenceTable heap_graph_reference_table_{&string_pool_, |
| 1079 | nullptr}; |
Mohammad Reza Zakerinasab | b06d185 | 2019-09-11 14:41:36 -0400 | [diff] [blame] | 1080 | |
| 1081 | tables::VulkanMemoryAllocationsTable vulkan_memory_allocations_table_{ |
| 1082 | &string_pool_, nullptr}; |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 1083 | }; |
| 1084 | |
| 1085 | } // namespace trace_processor |
| 1086 | } // namespace perfetto |
| 1087 | |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 1088 | namespace std { |
| 1089 | |
| 1090 | template <> |
Lalit Maganti | b0e11f6 | 2020-01-02 14:17:58 +0000 | [diff] [blame] | 1091 | struct hash<::perfetto::trace_processor::TrackId> { |
| 1092 | using argument_type = ::perfetto::trace_processor::TrackId; |
| 1093 | using result_type = size_t; |
| 1094 | |
| 1095 | result_type operator()(const argument_type& r) const { |
| 1096 | return std::hash<uint32_t>{}(r.value); |
| 1097 | } |
| 1098 | }; |
| 1099 | |
| 1100 | template <> |
Lalit Maganti | 0a29f6f | 2020-01-06 12:01:14 +0000 | [diff] [blame] | 1101 | struct hash<::perfetto::trace_processor::tables::StackProfileFrameTable::Row> { |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 1102 | using argument_type = |
Lalit Maganti | 0a29f6f | 2020-01-06 12:01:14 +0000 | [diff] [blame] | 1103 | ::perfetto::trace_processor::tables::StackProfileFrameTable::Row; |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 1104 | using result_type = size_t; |
| 1105 | |
| 1106 | result_type operator()(const argument_type& r) const { |
Lalit Maganti | 0a29f6f | 2020-01-06 12:01:14 +0000 | [diff] [blame] | 1107 | return std::hash<::perfetto::trace_processor::StringId>{}(r.name) ^ |
| 1108 | std::hash<int64_t>{}(r.mapping) ^ std::hash<int64_t>{}(r.rel_pc); |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 1109 | } |
| 1110 | }; |
| 1111 | |
| 1112 | template <> |
| 1113 | struct hash< |
Lalit Maganti | aa0ff5b | 2019-10-25 10:35:48 +0100 | [diff] [blame] | 1114 | ::perfetto::trace_processor::tables::StackProfileCallsiteTable::Row> { |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 1115 | using argument_type = |
Lalit Maganti | aa0ff5b | 2019-10-25 10:35:48 +0100 | [diff] [blame] | 1116 | ::perfetto::trace_processor::tables::StackProfileCallsiteTable::Row; |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 1117 | using result_type = size_t; |
| 1118 | |
| 1119 | result_type operator()(const argument_type& r) const { |
| 1120 | return std::hash<int64_t>{}(r.depth) ^ std::hash<int64_t>{}(r.parent_id) ^ |
Lalit Maganti | aa0ff5b | 2019-10-25 10:35:48 +0100 | [diff] [blame] | 1121 | std::hash<int64_t>{}(r.frame_id); |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 1122 | } |
| 1123 | }; |
| 1124 | |
| 1125 | template <> |
| 1126 | struct hash< |
Lalit Maganti | 45980c9 | 2019-12-20 13:17:44 +0000 | [diff] [blame] | 1127 | ::perfetto::trace_processor::tables::StackProfileMappingTable::Row> { |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 1128 | using argument_type = |
Lalit Maganti | 45980c9 | 2019-12-20 13:17:44 +0000 | [diff] [blame] | 1129 | ::perfetto::trace_processor::tables::StackProfileMappingTable::Row; |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 1130 | using result_type = size_t; |
| 1131 | |
| 1132 | result_type operator()(const argument_type& r) const { |
| 1133 | return std::hash<::perfetto::trace_processor::StringId>{}(r.build_id) ^ |
Florian Mayer | 1265573 | 2019-07-02 15:08:26 +0100 | [diff] [blame] | 1134 | std::hash<int64_t>{}(r.exact_offset) ^ |
| 1135 | std::hash<int64_t>{}(r.start_offset) ^ |
| 1136 | std::hash<int64_t>{}(r.start) ^ std::hash<int64_t>{}(r.end) ^ |
| 1137 | std::hash<int64_t>{}(r.load_bias) ^ |
Lalit Maganti | 45980c9 | 2019-12-20 13:17:44 +0000 | [diff] [blame] | 1138 | std::hash<::perfetto::trace_processor::StringId>{}(r.name); |
Florian Mayer | bee5213 | 2019-05-02 13:59:56 +0100 | [diff] [blame] | 1139 | } |
| 1140 | }; |
| 1141 | |
| 1142 | } // namespace std |
| 1143 | |
Lalit Maganti | caed37e | 2018-06-01 03:03:08 +0100 | [diff] [blame] | 1144 | #endif // SRC_TRACE_PROCESSOR_TRACE_STORAGE_H_ |