Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: base/trace_event/heap_profiler_event_writer.h

Issue 2650863003: [tracing] Switch to new heap dump format. (Closed)
Patch Set: DCHECK for continuous mode Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
Primiano Tucci (use gerrit) 2017/03/09 11:47:44 2017 :)
DmitrySkiba 2017/03/14 22:12:47 Done.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef BASE_TRACE_EVENT_HEAP_PROFILER_EVENT_WRITER_H_
6 #define BASE_TRACE_EVENT_HEAP_PROFILER_EVENT_WRITER_H_
7
8 #include <stddef.h>
9
10 #include <memory>
11 #include <string>
12 #include <unordered_map>
13
14 #include "base/base_export.h"
15
16 /*
17 Heap profile event data format.
Primiano Tucci (use gerrit) 2017/03/09 11:47:44 this comment is really awesome. thanks a lot, real
18
19 Input is:
20 1. Per allocator AllocationRegister
21 2. Per process deduplicators (for stack frames, types, strings)
22
23 Formatting event data has two steps:
24 1. Call ExportHeapDump() on allocation registers and accumulate results
Primiano Tucci (use gerrit) 2017/03/09 11:47:44 only have one small comment about naming: you have
DmitrySkiba 2017/03/14 22:12:47 Done. Going with Export -> Serialize.
25 in ExportedHeapDumpsMap. ExportHeapDump() exports allocation register
26 as "allocators/<allocator>" dictionary outlined below; deduplicators
27 contained in MemoryDumpSessionState are used in the process.
Primiano Tucci (use gerrit) 2017/03/09 11:47:44 s/in the process/in this stage/
DmitrySkiba 2017/03/14 22:12:47 Done.
28 2. Call ExportHeapProfileEventData() with ExportedHeapDumpsMap and
29 MemoryDumpSessionState. This puts everything together:
30 a. Entries from ExportedHeapDumpsMap are formatted as
31 "allocators/<allocator>" nodes.
32 b. Deduplicators from MemoryDumpSessionState are formatted as
33 "maps/" nodes. Deduplicators are exported incrementally using
34 their ExportIncrementally() methods.
35
36 ExportHeapDump() aggregates allocation register entries first by backtrace,
37 then by type (i.e. creates map {(backtrace, type) -> AllocationMetrics}).
38 During aggregation backtraces and types are deduplicated.
39
40 Resulting event data format:
41 {
42 "version": 1,
43
44 "allocators": {
45 <allocator>: {
Primiano Tucci (use gerrit) 2017/03/09 11:47:44 maybe, just to clarify, I'ld s/<allocator>/[malloc
DmitrySkiba 2017/03/14 22:12:47 Done.
46 "nodes": [<stack_frame_id1>, <stack_frame_id2>, ...],
47 "types": [<type_id1>, <type_id2>, ...],
48 "counts": [<count1>, <count2>, ...],
49 "sizes": [<size1>, <size1>, ...]
Primiano Tucci (use gerrit) 2017/03/09 11:47:44 I guess the 2nd one is size2?
DmitrySkiba 2017/03/14 22:12:47 Done.
50 }
51 },
52
53 "maps": {
54 "nodes": [
55 {
56 "id": <stack_frame_id>,
57 "parent": <parent_id>,
Primiano Tucci (use gerrit) 2017/03/09 11:47:44 not sure if this is going to affect too much the p
DmitrySkiba 2017/03/14 22:12:47 Yeah, we need to bikeshed that. We can do a pass a
Primiano Tucci (use gerrit) 2017/03/15 20:41:40 Alright. Agree that's definitely not a blocker for
58 "name_sid": <name_string_id>
59 },
60 ...
61 ],
62 "types": [
63 {
64 "id": <type_id>,
65 "name_sid": <name_string_id>
66 }
67 ],
68 "strings": [
69 {
70 "id": <string_id>,
71 "string": <string>
72 }
73 ]
74 }
75 }
76 */
77
78 namespace base {
79 namespace trace_event {
80
81 class AllocationRegister;
82 class MemoryDumpSessionState;
83 class TracedValue;
84
85 // Exports heap allocations as "allocators/<allocator>" dictionary described
86 // above. Return value is supposed to be added to ExportedHeapDumpsMap map
87 // and later passed to ExportHeapProfileEventData().
88 BASE_EXPORT std::unique_ptr<TracedValue> ExportHeapDump(
89 const AllocationRegister& allocation_register,
90 const MemoryDumpSessionState& session_state);
91
92 // Maps allocator name to its heap dump.
93 using ExportedHeapDumpsMap =
Primiano Tucci (use gerrit) 2017/03/09 11:47:44 yeah the more I look at this the more I think that
DmitrySkiba 2017/03/14 22:12:47 Done.
94 std::unordered_map<std::string, std::unique_ptr<TracedValue>>;
95
96 // Exports event data according to the format described above.
97 BASE_EXPORT std::unique_ptr<TracedValue> ExportHeapProfileEventData(
98 const ExportedHeapDumpsMap& heap_dumps,
99 const MemoryDumpSessionState& session_state);
100
101 } // namespace trace_event
102 } // namespace base
103
104 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_EVENT_WRITER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698