blob: c69636e993ef520819ceea4f011275f1ba0e176d [file] [log] [blame]
Lalit Maganticaed37e2018-06-01 03:03:08 +01001/*
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 Maganti35622b72018-06-06 12:03:11 +010020#include <array>
Lalit Maganticaed37e2018-06-01 03:03:08 +010021#include <deque>
Isabelle Taylor47328cf2018-06-12 14:33:59 +010022#include <map>
Lalit Maganticaed37e2018-06-01 03:03:08 +010023#include <string>
24#include <unordered_map>
25#include <vector>
26
Lalit Maganti35622b72018-06-06 12:03:11 +010027#include "perfetto/base/logging.h"
Lalit Maganti770886a2018-11-16 17:40:21 +000028#include "perfetto/base/optional.h"
Primiano Tucci2da5d2e2018-08-10 14:23:31 +010029#include "perfetto/base/string_view.h"
Hector Dearmanc8339932018-08-10 11:22:46 +010030#include "perfetto/base/utils.h"
Lalit Maganti35622b72018-06-06 12:03:11 +010031
Lalit Maganticaed37e2018-06-01 03:03:08 +010032namespace perfetto {
33namespace trace_processor {
34
Isabelle Taylora0a22972018-08-03 12:06:12 +010035// UniquePid is an offset into |unique_processes_|. This is necessary because
36// Unix pids are reused and thus not guaranteed to be unique over a long
37// period of time.
38using UniquePid = uint32_t;
Primiano Tucci0d72a312018-08-07 14:42:45 +010039
Isabelle Taylora0a22972018-08-03 12:06:12 +010040// UniqueTid is an offset into |unique_threads_|. Necessary because tids can
41// be reused.
42using UniqueTid = uint32_t;
43
Primiano Tucci0d72a312018-08-07 14:42:45 +010044// StringId is an offset into |string_pool_|.
45using StringId = size_t;
46
Lalit Maganti5ea9e932018-11-30 14:19:39 +000047// Identifiers for all the tables in the database.
48enum TableId : uint8_t {
49 // Intentionally don't have TableId == 0 so that RowId == 0 can refer to an
50 // invalid row id.
51 kCounters = 1,
52};
53
54// The top 8 bits are set to the TableId and the bottom 32 to the row of the
55// table.
56using RowId = uint64_t;
57
58static const RowId kInvalidRowId = 0;
59
Isabelle Taylora97c5f52018-10-23 17:36:12 +010060enum RefType {
Primiano Tucci5403e4f2018-11-27 10:07:03 +000061 kRefNoRef = 0,
62 kRefUtid = 1,
63 kRefCpuId = 2,
64 kRefIrq = 3,
65 kRefSoftIrq = 4,
66 kRefUpid = 5,
67 kRefUtidLookupUpid = 6,
68 kRefMax
Isabelle Taylora97c5f52018-10-23 17:36:12 +010069};
Isabelle Taylor14674d42018-09-07 11:33:11 +010070
Lalit Maganticaed37e2018-06-01 03:03:08 +010071// Stores a data inside a trace file in a columnar form. This makes it efficient
72// to read or search across a single field of the trace (e.g. all the thread
73// names for a given CPU).
74class TraceStorage {
75 public:
Isabelle Taylor47328cf2018-06-12 14:33:59 +010076 TraceStorage();
Isabelle Taylora0a22972018-08-03 12:06:12 +010077 TraceStorage(const TraceStorage&) = delete;
78
79 virtual ~TraceStorage();
Isabelle Taylor47328cf2018-06-12 14:33:59 +010080
Isabelle Taylora0a22972018-08-03 12:06:12 +010081 struct Stats {
Lalit Maganti6fdb9842018-11-12 11:00:00 +000082 uint64_t mismatched_sched_switch_tids = 0;
83 uint64_t rss_stat_no_process = 0;
84 uint64_t mem_counter_no_process = 0;
Isabelle Taylora0a22972018-08-03 12:06:12 +010085 };
Lalit Maganti35622b72018-06-06 12:03:11 +010086
Isabelle Taylora0a22972018-08-03 12:06:12 +010087 // Information about a unique process seen in a trace.
88 struct Process {
Primiano Tuccib75dcee2018-08-08 12:21:36 +010089 explicit Process(uint32_t p) : pid(p) {}
Isabelle Taylora0a22972018-08-03 12:06:12 +010090 uint64_t start_ns = 0;
91 uint64_t end_ns = 0;
92 StringId name_id = 0;
Primiano Tuccib75dcee2018-08-08 12:21:36 +010093 uint32_t pid = 0;
Isabelle Taylora0a22972018-08-03 12:06:12 +010094 };
95
96 // Information about a unique thread seen in a trace.
97 struct Thread {
Primiano Tuccib75dcee2018-08-08 12:21:36 +010098 explicit Thread(uint32_t t) : tid(t) {}
Isabelle Taylora0a22972018-08-03 12:06:12 +010099 uint64_t start_ns = 0;
100 uint64_t end_ns = 0;
101 StringId name_id = 0;
Lalit Maganti770886a2018-11-16 17:40:21 +0000102 base::Optional<UniquePid> upid;
Primiano Tuccib75dcee2018-08-08 12:21:36 +0100103 uint32_t tid = 0;
Isabelle Taylora0a22972018-08-03 12:06:12 +0100104 };
Isabelle Taylor3dd366c2018-06-22 16:21:41 +0100105
Lalit Maganti6e9c55e2018-11-29 12:00:39 +0000106 // Generic key value storage which can be referenced by other tables.
107 class Args {
108 public:
Lalit Maganti6e9c55e2018-11-29 12:00:39 +0000109 // Varardic type representing the possible values for the args table.
110 struct Varardic {
111 enum Type { kInt, kString, kReal };
112
113 Varardic(int64_t int_val) : type(kInt), int_value(int_val) {}
114 Varardic(StringId string_val) : type(kString), string_value(string_val) {}
115 Varardic(double real_val) : type(kReal), real_value(real_val) {}
116
117 Type type;
118 union {
119 int64_t int_value;
120 StringId string_value;
121 double real_value;
122 };
123 };
124
Lalit Maganti5ea9e932018-11-30 14:19:39 +0000125 const std::deque<RowId>& ids() const { return ids_; }
126 const std::deque<StringId>& flat_keys() const { return flat_keys_; }
127 const std::deque<StringId>& keys() const { return keys_; }
Lalit Maganti6e9c55e2018-11-29 12:00:39 +0000128 const std::deque<Varardic>& arg_values() const { return arg_values_; }
129 size_t args_count() const { return ids_.size(); }
130
Lalit Maganti5ea9e932018-11-30 14:19:39 +0000131 void AddArg(RowId id, StringId flat_key, StringId key, int64_t value) {
132 if (id == kInvalidRowId)
133 return;
134
135 ids_.emplace_back(id);
136 flat_keys_.emplace_back(flat_key);
137 keys_.emplace_back(key);
138 arg_values_.emplace_back(value);
139 args_for_id_.emplace(id, args_count() - 1);
Lalit Maganti6e9c55e2018-11-29 12:00:39 +0000140 }
141
Lalit Maganti5ea9e932018-11-30 14:19:39 +0000142 private:
143 std::deque<RowId> ids_;
144 std::deque<StringId> flat_keys_;
145 std::deque<StringId> keys_;
Lalit Maganti6e9c55e2018-11-29 12:00:39 +0000146 std::deque<Varardic> arg_values_;
Lalit Maganti5ea9e932018-11-30 14:19:39 +0000147 std::multimap<RowId, size_t> args_for_id_;
Lalit Maganti6e9c55e2018-11-29 12:00:39 +0000148 };
149
Lalit Magantiff69c112018-09-24 12:07:47 +0100150 class Slices {
Lalit Maganti35622b72018-06-06 12:03:11 +0100151 public:
Lalit Magantifde29042018-10-04 13:28:52 +0100152 inline size_t AddSlice(uint32_t cpu,
153 uint64_t start_ns,
154 uint64_t duration_ns,
155 UniqueTid utid) {
Lalit Magantiff69c112018-09-24 12:07:47 +0100156 cpus_.emplace_back(cpu);
Lalit Maganti35622b72018-06-06 12:03:11 +0100157 start_ns_.emplace_back(start_ns);
158 durations_.emplace_back(duration_ns);
Isabelle Taylora0a22972018-08-03 12:06:12 +0100159 utids_.emplace_back(utid);
Lalit Magantifde29042018-10-04 13:28:52 +0100160 return slice_count() - 1;
161 }
162
163 void set_duration(size_t index, uint64_t duration_ns) {
164 durations_[index] = duration_ns;
Lalit Maganti35622b72018-06-06 12:03:11 +0100165 }
166
Isabelle Taylor47328cf2018-06-12 14:33:59 +0100167 size_t slice_count() const { return start_ns_.size(); }
Lalit Maganti35622b72018-06-06 12:03:11 +0100168
Lalit Magantiff69c112018-09-24 12:07:47 +0100169 const std::deque<uint32_t>& cpus() const { return cpus_; }
170
Isabelle Taylor47328cf2018-06-12 14:33:59 +0100171 const std::deque<uint64_t>& start_ns() const { return start_ns_; }
Lalit Maganti35622b72018-06-06 12:03:11 +0100172
Isabelle Taylor47328cf2018-06-12 14:33:59 +0100173 const std::deque<uint64_t>& durations() const { return durations_; }
Lalit Maganti35622b72018-06-06 12:03:11 +0100174
Isabelle Taylor68e42192018-06-19 16:19:31 +0100175 const std::deque<UniqueTid>& utids() const { return utids_; }
176
Lalit Maganti35622b72018-06-06 12:03:11 +0100177 private:
Hector Dearman947f12a2018-09-11 16:50:36 +0100178 // Each deque below has the same number of entries (the number of slices
Lalit Maganti35622b72018-06-06 12:03:11 +0100179 // in the trace for the CPU).
Lalit Magantiff69c112018-09-24 12:07:47 +0100180 std::deque<uint32_t> cpus_;
Lalit Maganti35622b72018-06-06 12:03:11 +0100181 std::deque<uint64_t> start_ns_;
182 std::deque<uint64_t> durations_;
Isabelle Taylor68e42192018-06-19 16:19:31 +0100183 std::deque<UniqueTid> utids_;
Primiano Tucci0d72a312018-08-07 14:42:45 +0100184 };
Isabelle Taylor68e42192018-06-19 16:19:31 +0100185
Primiano Tucci0d72a312018-08-07 14:42:45 +0100186 class NestableSlices {
187 public:
Lalit Maganti7b37bbf2018-11-09 15:58:54 +0000188 inline size_t AddSlice(uint64_t start_ns,
189 uint64_t duration_ns,
190 UniqueTid utid,
191 StringId cat,
192 StringId name,
193 uint8_t depth,
194 uint64_t stack_id,
195 uint64_t parent_stack_id) {
Primiano Tucci0d72a312018-08-07 14:42:45 +0100196 start_ns_.emplace_back(start_ns);
197 durations_.emplace_back(duration_ns);
198 utids_.emplace_back(utid);
199 cats_.emplace_back(cat);
200 names_.emplace_back(name);
201 depths_.emplace_back(depth);
Primiano Tuccib75dcee2018-08-08 12:21:36 +0100202 stack_ids_.emplace_back(stack_id);
203 parent_stack_ids_.emplace_back(parent_stack_id);
Lalit Maganti7b37bbf2018-11-09 15:58:54 +0000204 return slice_count() - 1;
205 }
206
207 void set_duration(size_t index, uint64_t duration_ns) {
208 durations_[index] = duration_ns;
209 }
210
211 void set_stack_id(size_t index, uint64_t stack_id) {
212 stack_ids_[index] = stack_id;
Primiano Tucci0d72a312018-08-07 14:42:45 +0100213 }
214
215 size_t slice_count() const { return start_ns_.size(); }
216 const std::deque<uint64_t>& start_ns() const { return start_ns_; }
217 const std::deque<uint64_t>& durations() const { return durations_; }
218 const std::deque<UniqueTid>& utids() const { return utids_; }
219 const std::deque<StringId>& cats() const { return cats_; }
220 const std::deque<StringId>& names() const { return names_; }
221 const std::deque<uint8_t>& depths() const { return depths_; }
Primiano Tuccib75dcee2018-08-08 12:21:36 +0100222 const std::deque<uint64_t>& stack_ids() const { return stack_ids_; }
223 const std::deque<uint64_t>& parent_stack_ids() const {
224 return parent_stack_ids_;
225 }
Primiano Tucci0d72a312018-08-07 14:42:45 +0100226
227 private:
228 std::deque<uint64_t> start_ns_;
229 std::deque<uint64_t> durations_;
230 std::deque<UniqueTid> utids_;
231 std::deque<StringId> cats_;
232 std::deque<StringId> names_;
233 std::deque<uint8_t> depths_;
Primiano Tuccib75dcee2018-08-08 12:21:36 +0100234 std::deque<uint64_t> stack_ids_;
235 std::deque<uint64_t> parent_stack_ids_;
Lalit Maganti35622b72018-06-06 12:03:11 +0100236 };
237
Isabelle Taylor15314ea2018-09-19 11:35:19 +0100238 class Counters {
239 public:
Lalit Magantifde29042018-10-04 13:28:52 +0100240 inline size_t AddCounter(uint64_t timestamp,
241 uint64_t duration,
242 StringId name_id,
243 double value,
Lalit Magantifde29042018-10-04 13:28:52 +0100244 int64_t ref,
245 RefType type) {
Isabelle Taylor15314ea2018-09-19 11:35:19 +0100246 timestamps_.emplace_back(timestamp);
247 durations_.emplace_back(duration);
248 name_ids_.emplace_back(name_id);
249 values_.emplace_back(value);
250 refs_.emplace_back(ref);
251 types_.emplace_back(type);
Lalit Magantifde29042018-10-04 13:28:52 +0100252 return counter_count() - 1;
Isabelle Taylor15314ea2018-09-19 11:35:19 +0100253 }
Lalit Magantifde29042018-10-04 13:28:52 +0100254
255 void set_duration(size_t index, uint64_t duration) {
256 durations_[index] = duration;
257 }
258
Isabelle Taylor15314ea2018-09-19 11:35:19 +0100259 size_t counter_count() const { return timestamps_.size(); }
260
261 const std::deque<uint64_t>& timestamps() const { return timestamps_; }
262
263 const std::deque<uint64_t>& durations() const { return durations_; }
264
265 const std::deque<StringId>& name_ids() const { return name_ids_; }
266
267 const std::deque<double>& values() const { return values_; }
268
269 const std::deque<int64_t>& refs() const { return refs_; }
270
271 const std::deque<RefType>& types() const { return types_; }
272
273 private:
274 std::deque<uint64_t> timestamps_;
275 std::deque<uint64_t> durations_;
276 std::deque<StringId> name_ids_;
277 std::deque<double> values_;
278 std::deque<int64_t> refs_;
279 std::deque<RefType> types_;
280 };
281
Primiano Tucci5cb84f82018-10-31 21:46:36 -0700282 class SqlStats {
283 public:
284 static constexpr size_t kMaxLogEntries = 100;
285 void RecordQueryBegin(const std::string& query,
286 uint64_t time_queued,
287 uint64_t time_started);
288 void RecordQueryEnd(uint64_t time_ended);
289 size_t size() const { return queries_.size(); }
290 const std::deque<std::string>& queries() const { return queries_; }
291 const std::deque<uint64_t>& times_queued() const { return times_queued_; }
292 const std::deque<uint64_t>& times_started() const { return times_started_; }
293 const std::deque<uint64_t>& times_ended() const { return times_ended_; }
294
295 private:
296 std::deque<std::string> queries_;
297 std::deque<uint64_t> times_queued_;
298 std::deque<uint64_t> times_started_;
299 std::deque<uint64_t> times_ended_;
300 };
301
Isabelle Taylorc8c11202018-11-05 11:36:22 +0000302 class Instants {
303 public:
304 inline size_t AddInstantEvent(uint64_t timestamp,
305 StringId name_id,
306 double value,
307 int64_t ref,
308 RefType type) {
309 timestamps_.emplace_back(timestamp);
310 name_ids_.emplace_back(name_id);
311 values_.emplace_back(value);
312 refs_.emplace_back(ref);
313 types_.emplace_back(type);
314 return instant_count() - 1;
315 }
316
317 size_t instant_count() const { return timestamps_.size(); }
318
319 const std::deque<uint64_t>& timestamps() const { return timestamps_; }
320
321 const std::deque<StringId>& name_ids() const { return name_ids_; }
322
323 const std::deque<double>& values() const { return values_; }
324
325 const std::deque<int64_t>& refs() const { return refs_; }
326
327 const std::deque<RefType>& types() const { return types_; }
328
329 private:
330 std::deque<uint64_t> timestamps_;
331 std::deque<StringId> name_ids_;
332 std::deque<double> values_;
333 std::deque<int64_t> refs_;
334 std::deque<RefType> types_;
335 };
336
Isabelle Taylora0a22972018-08-03 12:06:12 +0100337 void ResetStorage();
Lalit Maganti35622b72018-06-06 12:03:11 +0100338
Primiano Tuccib75dcee2018-08-08 12:21:36 +0100339 UniqueTid AddEmptyThread(uint32_t tid) {
340 unique_threads_.emplace_back(tid);
Isabelle Taylora0a22972018-08-03 12:06:12 +0100341 return static_cast<UniqueTid>(unique_threads_.size() - 1);
342 }
Isabelle Taylor47328cf2018-06-12 14:33:59 +0100343
Primiano Tuccib75dcee2018-08-08 12:21:36 +0100344 UniquePid AddEmptyProcess(uint32_t pid) {
345 unique_processes_.emplace_back(pid);
Isabelle Taylora0a22972018-08-03 12:06:12 +0100346 return static_cast<UniquePid>(unique_processes_.size() - 1);
347 }
Isabelle Taylor3dd366c2018-06-22 16:21:41 +0100348
Isabelle Taylora0a22972018-08-03 12:06:12 +0100349 // Return an unqiue identifier for the contents of each string.
350 // The string is copied internally and can be destroyed after this called.
Isabelle Taylor15314ea2018-09-19 11:35:19 +0100351 // Virtual for testing.
352 virtual StringId InternString(base::StringView);
Isabelle Taylor47328cf2018-06-12 14:33:59 +0100353
Isabelle Taylora0a22972018-08-03 12:06:12 +0100354 Process* GetMutableProcess(UniquePid upid) {
Lalit Maganti676658b2018-11-20 18:24:31 +0000355 PERFETTO_DCHECK(upid < unique_processes_.size());
Isabelle Taylora0a22972018-08-03 12:06:12 +0100356 return &unique_processes_[upid];
357 }
Isabelle Taylor3dd366c2018-06-22 16:21:41 +0100358
Isabelle Taylora0a22972018-08-03 12:06:12 +0100359 Thread* GetMutableThread(UniqueTid utid) {
Florian Mayera1aaec22018-09-19 17:02:26 +0100360 PERFETTO_DCHECK(utid < unique_threads_.size());
Isabelle Taylora0a22972018-08-03 12:06:12 +0100361 return &unique_threads_[utid];
362 }
Isabelle Taylor3dd366c2018-06-22 16:21:41 +0100363
Lalit Maganticaed37e2018-06-01 03:03:08 +0100364 // Reading methods.
Isabelle Taylora0a22972018-08-03 12:06:12 +0100365 const std::string& GetString(StringId id) const {
366 PERFETTO_DCHECK(id < string_pool_.size());
367 return string_pool_[id];
368 }
369
Lalit Magantie9d40532018-06-29 13:15:06 +0100370 const Process& GetProcess(UniquePid upid) const {
Lalit Maganti676658b2018-11-20 18:24:31 +0000371 PERFETTO_DCHECK(upid < unique_processes_.size());
Isabelle Taylor47328cf2018-06-12 14:33:59 +0100372 return unique_processes_[upid];
373 }
374
Lalit Magantie9d40532018-06-29 13:15:06 +0100375 const Thread& GetThread(UniqueTid utid) const {
Lalit Maganti1f64cfa2018-09-18 13:20:02 +0100376 // Allow utid == 0 for idle thread retrieval.
Florian Mayera1aaec22018-09-19 17:02:26 +0100377 PERFETTO_DCHECK(utid < unique_threads_.size());
Isabelle Taylor68e42192018-06-19 16:19:31 +0100378 return unique_threads_[utid];
379 }
380
Lalit Maganti5ea9e932018-11-30 14:19:39 +0000381 static RowId CreateRowId(TableId table, uint32_t row) {
382 static constexpr uint8_t kRowIdTableShift = 32;
383 return (static_cast<uint64_t>(table) << kRowIdTableShift) | row;
384 }
385
Lalit Magantiff69c112018-09-24 12:07:47 +0100386 const Slices& slices() const { return slices_; }
Lalit Magantifde29042018-10-04 13:28:52 +0100387 Slices* mutable_slices() { return &slices_; }
388
Primiano Tucci0d72a312018-08-07 14:42:45 +0100389 const NestableSlices& nestable_slices() const { return nestable_slices_; }
390 NestableSlices* mutable_nestable_slices() { return &nestable_slices_; }
391
Isabelle Taylor15314ea2018-09-19 11:35:19 +0100392 const Counters& counters() const { return counters_; }
393 Counters* mutable_counters() { return &counters_; }
Isabelle Taylor14674d42018-09-07 11:33:11 +0100394
Primiano Tucci5cb84f82018-10-31 21:46:36 -0700395 const SqlStats& sql_stats() const { return sql_stats_; }
396 SqlStats* mutable_sql_stats() { return &sql_stats_; }
397
Isabelle Taylorc8c11202018-11-05 11:36:22 +0000398 const Instants& instants() const { return instants_; }
399 Instants* mutable_instants() { return &instants_; }
400
Lalit Maganti05e8c132018-11-09 18:16:12 +0000401 const Stats& stats() const { return stats_; }
402 Stats* mutable_stats() { return &stats_; }
403
Lalit Maganti6e9c55e2018-11-29 12:00:39 +0000404 const Args& args() const { return args_; }
405 Args* mutable_args() { return &args_; }
406
Lalit Magantiacda68b2018-10-29 15:23:25 +0000407 const std::deque<std::string>& string_pool() const { return string_pool_; }
408
Isabelle Taylore7003fb2018-07-17 11:39:01 +0100409 // |unique_processes_| always contains at least 1 element becuase the 0th ID
410 // is reserved to indicate an invalid process.
411 size_t process_count() const { return unique_processes_.size() - 1; }
Primiano Tucci0d72a312018-08-07 14:42:45 +0100412
Isabelle Taylore7003fb2018-07-17 11:39:01 +0100413 // |unique_threads_| always contains at least 1 element becuase the 0th ID
414 // is reserved to indicate an invalid thread.
415 size_t thread_count() const { return unique_threads_.size() - 1; }
416
Hector Dearman12323362018-08-09 16:09:28 +0100417 // Number of interned strings in the pool. Includes the empty string w/ ID=0.
418 size_t string_count() const { return string_pool_.size(); }
419
Lalit Maganticaed37e2018-06-01 03:03:08 +0100420 private:
Isabelle Taylora0a22972018-08-03 12:06:12 +0100421 TraceStorage& operator=(const TraceStorage&) = default;
422
Primiano Tucci2da5d2e2018-08-10 14:23:31 +0100423 using StringHash = uint64_t;
Lalit Maganticaed37e2018-06-01 03:03:08 +0100424
Lalit Maganti05e8c132018-11-09 18:16:12 +0000425 // Stats about parsing the trace.
Lalit Maganti35622b72018-06-06 12:03:11 +0100426 Stats stats_;
427
Lalit Maganticaed37e2018-06-01 03:03:08 +0100428 // One entry for each CPU in the trace.
Lalit Magantiff69c112018-09-24 12:07:47 +0100429 Slices slices_;
Lalit Maganticaed37e2018-06-01 03:03:08 +0100430
Lalit Maganti6e9c55e2018-11-29 12:00:39 +0000431 // Args for all other tables.
432 Args args_;
433
Lalit Maganticaed37e2018-06-01 03:03:08 +0100434 // One entry for each unique string in the trace.
Lalit Maganti35622b72018-06-06 12:03:11 +0100435 std::deque<std::string> string_pool_;
Lalit Maganticaed37e2018-06-01 03:03:08 +0100436
437 // One entry for each unique string in the trace.
Lalit Maganti35622b72018-06-06 12:03:11 +0100438 std::unordered_map<StringHash, StringId> string_index_;
Isabelle Taylor47328cf2018-06-12 14:33:59 +0100439
Isabelle Taylor47328cf2018-06-12 14:33:59 +0100440 // One entry for each UniquePid, with UniquePid as the index.
Isabelle Taylor3dd366c2018-06-22 16:21:41 +0100441 std::deque<Process> unique_processes_;
Isabelle Taylor68e42192018-06-19 16:19:31 +0100442
Isabelle Taylor68e42192018-06-19 16:19:31 +0100443 // One entry for each UniqueTid, with UniqueTid as the index.
Isabelle Taylor3dd366c2018-06-22 16:21:41 +0100444 std::deque<Thread> unique_threads_;
Primiano Tucci0d72a312018-08-07 14:42:45 +0100445
446 // Slices coming from userspace events (e.g. Chromium TRACE_EVENT macros).
447 NestableSlices nestable_slices_;
Isabelle Taylor15314ea2018-09-19 11:35:19 +0100448
449 // Counter events from the trace. This includes CPU frequency events as well
450 // systrace trace_marker counter events.
451 Counters counters_;
Primiano Tucci5cb84f82018-10-31 21:46:36 -0700452
453 SqlStats sql_stats_;
Lalit Maganti6e9c55e2018-11-29 12:00:39 +0000454
Isabelle Taylorc8c11202018-11-05 11:36:22 +0000455 // These are instantaneous events in the trace. They have no duration
456 // and do not have a value that make sense to track over time.
457 // e.g. signal events
458 Instants instants_;
Lalit Maganticaed37e2018-06-01 03:03:08 +0100459};
460
461} // namespace trace_processor
462} // namespace perfetto
463
464#endif // SRC_TRACE_PROCESSOR_TRACE_STORAGE_H_