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

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

Issue 2650863003: [tracing] Switch to new heap dump format. (Closed)
Patch Set: Rebase Created 3 years, 6 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
« no previous file with comments | « base/BUILD.gn ('k') | base/trace_event/heap_profiler_event_writer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
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 is done in two steps:
24 1. Call SerializeHeapDump() on allocation registers and accumulate
25 results in SerializedHeapDumpsMap. SerializeHeapDump() exports
26 allocation register as "allocators/<allocator>" dictionary outlined
27 below; serialization uses deduplicators from MemoryDumpSessionState.
28 2. Call SerializeHeapProfileEventData() with SerializedHeapDumpsMap and
29 MemoryDumpSessionState. This puts everything together:
30 a. Entries from SerializedHeapDumpsMap 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 SerializeHeapDump() 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 ["malloc", "partition_alloc", "blinkgc"]: {
46 "nodes": [<stack_frame_id1>, <stack_frame_id2>, ...],
47 "types": [<type_id1>, <type_id2>, ...],
48 "counts": [<count1>, <count2>, ...],
49 "sizes": [<size1>, <size2>, ...]
50 }
51 },
52
53 "maps": {
54 "nodes": [
55 {
56 "id": <stack_frame_id>,
57 "parent": <parent_id>,
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 ShardedAllocationRegister;
82 class HeapProfilerSerializationState;
83 class TracedValue;
84
85 // Exports heap allocations as "allocators/<allocator>" dictionary described
86 // above. Return value is supposed to be added to SerializedHeapDumpsMap map
87 // and later passed to SerializeHeapProfileEventData().
88 BASE_EXPORT std::unique_ptr<TracedValue> SerializeHeapDump(
89 const ShardedAllocationRegister& allocation_register,
90 HeapProfilerSerializationState* serialization_state);
91
92 // Maps allocator name to its heap dump.
93 using SerializedHeapDumpsMap =
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> SerializeHeapProfileEventData(
98 const SerializedHeapDumpsMap& heap_dumps,
99 HeapProfilerSerializationState* serialization_state);
100
101 } // namespace trace_event
102 } // namespace base
103
104 #endif // BASE_TRACE_EVENT_HEAP_PROFILER_EVENT_WRITER_H_
OLDNEW
« no previous file with comments | « base/BUILD.gn ('k') | base/trace_event/heap_profiler_event_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698