OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
ssid
2017/03/13 03:38:00
2017 all files
DmitrySkiba
2017/03/14 22:12:48
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. | |
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 | |
25 in ExportedHeapDumpsMap. ExportHeapDump() exports allocation register | |
26 as "allocators/<allocator>" dictionary outlined below; deduplicators | |
27 contained in MemoryDumpSessionState are used in the process. | |
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>: { | |
46 "nodes": [<stack_frame_id1>, <stack_frame_id2>, ...], | |
47 "types": [<type_id1>, <type_id2>, ...], | |
48 "counts": [<count1>, <count2>, ...], | |
49 "sizes": [<size1>, <size1>, ...] | |
50 } | |
51 }, | |
52 | |
53 "maps": { | |
54 "nodes": [ | |
55 { | |
56 "id": <stack_frame_id>, | |
57 "parent": <parent_id>, | |
58 "name_sid": <name_string_id> | |
ssid
2017/03/13 03:38:00
Have you considered naming this just sid? name doe
DmitrySkiba
2017/03/14 22:12:48
I think it should be just 'name', but we can bikes
| |
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 = | |
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_ | |
OLD | NEW |