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

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

Issue 2911263003: [memory-infra] Add method to override importance of ownership edges (Closed)
Patch Set: 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/trace_event/memory_allocator_dump_guid.h ('k') | base/trace_event/process_memory_dump.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ 5 #ifndef BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_
6 #define BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ 6 #define BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <unordered_map> 10 #include <unordered_map>
(...skipping 21 matching lines...) Expand all
32 namespace trace_event { 32 namespace trace_event {
33 33
34 class MemoryDumpSessionState; 34 class MemoryDumpSessionState;
35 class TracedValue; 35 class TracedValue;
36 36
37 // ProcessMemoryDump is as a strongly typed container which holds the dumps 37 // ProcessMemoryDump is as a strongly typed container which holds the dumps
38 // produced by the MemoryDumpProvider(s) for a specific process. 38 // produced by the MemoryDumpProvider(s) for a specific process.
39 class BASE_EXPORT ProcessMemoryDump { 39 class BASE_EXPORT ProcessMemoryDump {
40 public: 40 public:
41 struct MemoryAllocatorDumpEdge { 41 struct MemoryAllocatorDumpEdge {
42 MemoryAllocatorDumpGuid source;
43 MemoryAllocatorDumpGuid target; 42 MemoryAllocatorDumpGuid target;
44 int importance; 43 int importance;
45 const char* type; 44 const char* type;
45 bool overridable;
46 }; 46 };
47 47
48 // Maps allocator dumps absolute names (allocator_name/heap/subheap) to 48 // Maps allocator dumps absolute names (allocator_name/heap/subheap) to
49 // MemoryAllocatorDump instances. 49 // MemoryAllocatorDump instances.
50 using AllocatorDumpsMap = 50 using AllocatorDumpsMap =
51 std::unordered_map<std::string, std::unique_ptr<MemoryAllocatorDump>>; 51 std::unordered_map<std::string, std::unique_ptr<MemoryAllocatorDump>>;
52 52
53 using HeapDumpsMap = 53 using HeapDumpsMap =
54 std::unordered_map<std::string, std::unique_ptr<TracedValue>>; 54 std::unordered_map<std::string, std::unique_ptr<TracedValue>>;
55 55
56 using AllocatorDumpEdgesMap =
57 std::unordered_map<MemoryAllocatorDumpGuid, MemoryAllocatorDumpEdge>;
hajimehoshi 2017/05/31 05:45:51 Just std::map might be better (See /base/container
ssid 2017/06/02 23:14:46 Done
58
56 #if defined(COUNT_RESIDENT_BYTES_SUPPORTED) 59 #if defined(COUNT_RESIDENT_BYTES_SUPPORTED)
57 // Returns the number of bytes in a kernel memory page. Some platforms may 60 // Returns the number of bytes in a kernel memory page. Some platforms may
58 // have a different value for kernel page sizes from user page sizes. It is 61 // have a different value for kernel page sizes from user page sizes. It is
59 // important to use kernel memory page sizes for resident bytes calculation. 62 // important to use kernel memory page sizes for resident bytes calculation.
60 // In most cases, the two are the same. 63 // In most cases, the two are the same.
61 static size_t GetSystemPageSize(); 64 static size_t GetSystemPageSize();
62 65
63 // Returns the total bytes resident for a virtual address range, with given 66 // Returns the total bytes resident for a virtual address range, with given
64 // |start_address| and |mapped_size|. |mapped_size| is specified in bytes. The 67 // |start_address| and |mapped_size|. |mapped_size| is specified in bytes. The
65 // value returned is valid only if the given range is currently mmapped by the 68 // value returned is valid only if the given range is currently mmapped by the
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 // semantics: |source| owns |target|, and has the effect of attributing 131 // semantics: |source| owns |target|, and has the effect of attributing
129 // the memory usage of |target| to |source|. |importance| is optional and 132 // the memory usage of |target| to |source|. |importance| is optional and
130 // relevant only for the cases of co-ownership, where it acts as a z-index: 133 // relevant only for the cases of co-ownership, where it acts as a z-index:
131 // the owner with the highest importance will be attributed |target|'s memory. 134 // the owner with the highest importance will be attributed |target|'s memory.
132 void AddOwnershipEdge(const MemoryAllocatorDumpGuid& source, 135 void AddOwnershipEdge(const MemoryAllocatorDumpGuid& source,
133 const MemoryAllocatorDumpGuid& target, 136 const MemoryAllocatorDumpGuid& target,
134 int importance); 137 int importance);
135 void AddOwnershipEdge(const MemoryAllocatorDumpGuid& source, 138 void AddOwnershipEdge(const MemoryAllocatorDumpGuid& source,
136 const MemoryAllocatorDumpGuid& target); 139 const MemoryAllocatorDumpGuid& target);
137 140
138 const std::vector<MemoryAllocatorDumpEdge>& allocator_dumps_edges() const { 141 void CreateSharedMemoryOwnershipEdge(
142 const MemoryAllocatorDumpGuid& client_dump_guid,
143 const MemoryAllocatorDumpGuid& client_global_dump_guid,
144 bool is_weak,
145 int importance,
146 uint64_t shm_unguessable_token);
147
148 const AllocatorDumpEdgesMap& allocator_dumps_edges_for_testing() const {
139 return allocator_dumps_edges_; 149 return allocator_dumps_edges_;
140 } 150 }
141 151
142 // Utility method to add a suballocation relationship with the following 152 // Utility method to add a suballocation relationship with the following
143 // semantics: |source| is suballocated from |target_node_name|. 153 // semantics: |source| is suballocated from |target_node_name|.
144 // This creates a child node of |target_node_name| and adds an ownership edge 154 // This creates a child node of |target_node_name| and adds an ownership edge
145 // between |source| and the new child node. As a result, the UI will not 155 // between |source| and the new child node. As a result, the UI will not
146 // account the memory of |source| in the target node. 156 // account the memory of |source| in the target node.
147 void AddSuballocation(const MemoryAllocatorDumpGuid& source, 157 void AddSuballocation(const MemoryAllocatorDumpGuid& source,
148 const std::string& target_node_name); 158 const std::string& target_node_name);
(...skipping 25 matching lines...) Expand all
174 ProcessMemoryMaps* process_mmaps() { return &process_mmaps_; } 184 ProcessMemoryMaps* process_mmaps() { return &process_mmaps_; }
175 bool has_process_mmaps() const { return has_process_mmaps_; } 185 bool has_process_mmaps() const { return has_process_mmaps_; }
176 void set_has_process_mmaps() { has_process_mmaps_ = true; } 186 void set_has_process_mmaps() { has_process_mmaps_ = true; }
177 187
178 const HeapDumpsMap& heap_dumps() const { return heap_dumps_; } 188 const HeapDumpsMap& heap_dumps() const { return heap_dumps_; }
179 189
180 const MemoryDumpArgs& dump_args() const { return dump_args_; } 190 const MemoryDumpArgs& dump_args() const { return dump_args_; }
181 191
182 private: 192 private:
183 FRIEND_TEST_ALL_PREFIXES(ProcessMemoryDumpTest, BackgroundModeTest); 193 FRIEND_TEST_ALL_PREFIXES(ProcessMemoryDumpTest, BackgroundModeTest);
194 FRIEND_TEST_ALL_PREFIXES(ProcessMemoryDumpTest, OverrideOwnershipEdge);
184 195
185 MemoryAllocatorDump* AddAllocatorDumpInternal( 196 MemoryAllocatorDump* AddAllocatorDumpInternal(
186 std::unique_ptr<MemoryAllocatorDump> mad); 197 std::unique_ptr<MemoryAllocatorDump> mad);
187 198
188 MemoryAllocatorDump* GetBlackHoleMad(); 199 MemoryAllocatorDump* GetBlackHoleMad();
189 200
201 void AddOverridableOwnershipEdge(const MemoryAllocatorDumpGuid& source,
202 const MemoryAllocatorDumpGuid& target,
203 int importance);
204
190 ProcessMemoryTotals process_totals_; 205 ProcessMemoryTotals process_totals_;
191 bool has_process_totals_; 206 bool has_process_totals_;
192 207
193 ProcessMemoryMaps process_mmaps_; 208 ProcessMemoryMaps process_mmaps_;
194 bool has_process_mmaps_; 209 bool has_process_mmaps_;
195 210
196 AllocatorDumpsMap allocator_dumps_; 211 AllocatorDumpsMap allocator_dumps_;
197 HeapDumpsMap heap_dumps_; 212 HeapDumpsMap heap_dumps_;
198 213
199 // State shared among all PMDs instances created in a given trace session. 214 // State shared among all PMDs instances created in a given trace session.
200 scoped_refptr<MemoryDumpSessionState> session_state_; 215 scoped_refptr<MemoryDumpSessionState> session_state_;
201 216
202 // Keeps track of relationships between MemoryAllocatorDump(s). 217 // Keeps track of relationships between MemoryAllocatorDump(s).
203 std::vector<MemoryAllocatorDumpEdge> allocator_dumps_edges_; 218 AllocatorDumpEdgesMap allocator_dumps_edges_;
204 219
205 // Level of detail of the current dump. 220 // Level of detail of the current dump.
206 const MemoryDumpArgs dump_args_; 221 const MemoryDumpArgs dump_args_;
207 222
208 // This allocator dump is returned when an invalid dump is created in 223 // This allocator dump is returned when an invalid dump is created in
209 // background mode. The attributes of the dump are ignored and not added to 224 // background mode. The attributes of the dump are ignored and not added to
210 // the trace. 225 // the trace.
211 std::unique_ptr<MemoryAllocatorDump> black_hole_mad_; 226 std::unique_ptr<MemoryAllocatorDump> black_hole_mad_;
212 227
213 // When set to true, the DCHECK(s) for invalid dump creations on the 228 // When set to true, the DCHECK(s) for invalid dump creations on the
214 // background mode are disabled for testing. 229 // background mode are disabled for testing.
215 static bool is_black_hole_non_fatal_for_testing_; 230 static bool is_black_hole_non_fatal_for_testing_;
216 231
217 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDump); 232 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDump);
218 }; 233 };
219 234
220 } // namespace trace_event 235 } // namespace trace_event
221 } // namespace base 236 } // namespace base
222 237
223 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_ 238 #endif // BASE_TRACE_EVENT_PROCESS_MEMORY_DUMP_H_
OLDNEW
« no previous file with comments | « base/trace_event/memory_allocator_dump_guid.h ('k') | base/trace_event/process_memory_dump.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698