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

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

Issue 1427963002: [tracing] Move memory-infra dumps to dedicated thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@memory-infra-names
Patch Set: remove extra reset() Created 5 years, 1 month 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 | « no previous file | base/trace_event/memory_dump_manager.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_MEMORY_DUMP_MANAGER_H_ 5 #ifndef BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_
6 #define BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ 6 #define BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "base/atomicops.h" 10 #include "base/atomicops.h"
11 #include "base/containers/hash_tables.h" 11 #include "base/containers/hash_tables.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.h"
14 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
15 #include "base/timer/timer.h" 15 #include "base/timer/timer.h"
16 #include "base/trace_event/memory_dump_request_args.h" 16 #include "base/trace_event/memory_dump_request_args.h"
17 #include "base/trace_event/process_memory_dump.h" 17 #include "base/trace_event/process_memory_dump.h"
18 #include "base/trace_event/trace_event.h" 18 #include "base/trace_event/trace_event.h"
19 19
20 namespace base { 20 namespace base {
21 21
22 class SingleThreadTaskRunner; 22 class SingleThreadTaskRunner;
23 class Thread;
23 24
24 namespace trace_event { 25 namespace trace_event {
25 26
26 class MemoryDumpManagerDelegate; 27 class MemoryDumpManagerDelegate;
27 class MemoryDumpProvider; 28 class MemoryDumpProvider;
28 class MemoryDumpSessionState; 29 class MemoryDumpSessionState;
29 30
30 // This is the interface exposed to the rest of the codebase to deal with 31 // This is the interface exposed to the rest of the codebase to deal with
31 // memory tracing. The main entry point for clients is represented by 32 // memory tracing. The main entry point for clients is represented by
32 // RequestDumpPoint(). The extension by Un(RegisterDumpProvider). 33 // RequestDumpPoint(). The extension by Un(RegisterDumpProvider).
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 using MemoryDumpProviderInfoSet = std::set<MemoryDumpProviderInfo>; 153 using MemoryDumpProviderInfoSet = std::set<MemoryDumpProviderInfo>;
153 154
154 // Holds the state of a process memory dump that needs to be carried over 155 // Holds the state of a process memory dump that needs to be carried over
155 // across threads in order to fulfil an asynchronous CreateProcessDump() 156 // across threads in order to fulfil an asynchronous CreateProcessDump()
156 // request. At any time exactly one thread owns a ProcessMemoryDumpAsyncState. 157 // request. At any time exactly one thread owns a ProcessMemoryDumpAsyncState.
157 struct ProcessMemoryDumpAsyncState { 158 struct ProcessMemoryDumpAsyncState {
158 ProcessMemoryDumpAsyncState( 159 ProcessMemoryDumpAsyncState(
159 MemoryDumpRequestArgs req_args, 160 MemoryDumpRequestArgs req_args,
160 MemoryDumpProviderInfoSet::iterator next_dump_provider, 161 MemoryDumpProviderInfoSet::iterator next_dump_provider,
161 const scoped_refptr<MemoryDumpSessionState>& session_state, 162 const scoped_refptr<MemoryDumpSessionState>& session_state,
162 MemoryDumpCallback callback); 163 MemoryDumpCallback callback,
164 const scoped_refptr<SingleThreadTaskRunner>& dump_thread_task_runner);
163 ~ProcessMemoryDumpAsyncState(); 165 ~ProcessMemoryDumpAsyncState();
164 166
165 // The ProcessMemoryDump container, where each dump provider will dump its 167 // The ProcessMemoryDump container, where each dump provider will dump its
166 // own MemoryAllocatorDump(s) upon the OnMemoryDump() call. 168 // own MemoryAllocatorDump(s) upon the OnMemoryDump() call.
167 ProcessMemoryDump process_memory_dump; 169 ProcessMemoryDump process_memory_dump;
168 170
169 // The arguments passed to the initial CreateProcessDump() request. 171 // The arguments passed to the initial CreateProcessDump() request.
170 const MemoryDumpRequestArgs req_args; 172 const MemoryDumpRequestArgs req_args;
171 173
172 // The |dump_providers_| iterator to the next dump provider that should be 174 // The |dump_providers_| iterator to the next dump provider that should be
173 // invoked (or dump_providers_.end() if at the end of the sequence). 175 // invoked (or dump_providers_.end() if at the end of the sequence).
174 MemoryDumpProviderInfoSet::iterator next_dump_provider; 176 MemoryDumpProviderInfoSet::iterator next_dump_provider;
175 177
176 // Callback passed to the initial call to CreateProcessDump(). 178 // Callback passed to the initial call to CreateProcessDump().
177 MemoryDumpCallback callback; 179 MemoryDumpCallback callback;
178 180
179 // The thread on which FinalizeDumpAndAddToTrace() (and hence |callback|) 181 // The thread on which FinalizeDumpAndAddToTrace() (and hence |callback|)
180 // should be invoked. This is the thread on which the initial 182 // should be invoked. This is the thread on which the initial
181 // CreateProcessDump() request was called. 183 // CreateProcessDump() request was called.
182 const scoped_refptr<SingleThreadTaskRunner> task_runner; 184 const scoped_refptr<SingleThreadTaskRunner> callback_task_runner;
185
186 // The thread on which unbound dump providers should be invoked.
187 // This is essentially |dump_thread_|.task_runner() but needs to be kept
188 // as a separate variable as it needs to be accessed by arbitrary dumpers'
189 // threads outside of the lock_ to avoid races when disabling tracing.
190 // It is immutable for all the duration of a tracing session.
191 const scoped_refptr<SingleThreadTaskRunner> dump_thread_task_runner;
183 192
184 private: 193 private:
185 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDumpAsyncState); 194 DISALLOW_COPY_AND_ASSIGN(ProcessMemoryDumpAsyncState);
186 }; 195 };
187 196
188 static const int kMaxConsecutiveFailuresCount; 197 static const int kMaxConsecutiveFailuresCount;
189 static const char* const kSystemAllocatorPoolName; 198 static const char* const kSystemAllocatorPoolName;
190 199
191 MemoryDumpManager(); 200 MemoryDumpManager();
192 ~MemoryDumpManager() override; 201 ~MemoryDumpManager() override;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 // to guard against disabling logging while dumping on another thread. 235 // to guard against disabling logging while dumping on another thread.
227 Lock lock_; 236 Lock lock_;
228 237
229 // Optimization to avoid attempting any memory dump (i.e. to not walk an empty 238 // Optimization to avoid attempting any memory dump (i.e. to not walk an empty
230 // dump_providers_enabled_ list) when tracing is not enabled. 239 // dump_providers_enabled_ list) when tracing is not enabled.
231 subtle::AtomicWord memory_tracing_enabled_; 240 subtle::AtomicWord memory_tracing_enabled_;
232 241
233 // For time-triggered periodic dumps. 242 // For time-triggered periodic dumps.
234 RepeatingTimer periodic_dump_timer_; 243 RepeatingTimer periodic_dump_timer_;
235 244
245 // Thread used for MemoryDumpProviders which don't specify a thread affinity.
246 scoped_ptr<Thread> dump_thread_;
247
236 // The unique id of the child process. This is created only for tracing and is 248 // The unique id of the child process. This is created only for tracing and is
237 // expected to be valid only when tracing is enabled. 249 // expected to be valid only when tracing is enabled.
238 uint64_t tracing_process_id_; 250 uint64_t tracing_process_id_;
239 251
240 // When true, calling |RegisterMemoryDumpProvider| is a no-op. 252 // When true, calling |RegisterMemoryDumpProvider| is a no-op.
241 bool dumper_registrations_ignored_for_testing_; 253 bool dumper_registrations_ignored_for_testing_;
242 254
243 // Whether new memory dump providers should be told to enable heap profiling. 255 // Whether new memory dump providers should be told to enable heap profiling.
244 bool heap_profiling_enabled_; 256 bool heap_profiling_enabled_;
245 257
(...skipping 21 matching lines...) Expand all
267 } 279 }
268 280
269 private: 281 private:
270 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegate); 282 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegate);
271 }; 283 };
272 284
273 } // namespace trace_event 285 } // namespace trace_event
274 } // namespace base 286 } // namespace base
275 287
276 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ 288 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | base/trace_event/memory_dump_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698