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

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

Issue 2537363003: [memory-infra] Add support for polling memory totals in MemoryDumpManager (Closed)
Patch Set: nits. Created 4 years 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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 scoped_refptr<SequencedTaskRunner> task_runner, 87 scoped_refptr<SequencedTaskRunner> task_runner,
88 MemoryDumpProvider::Options options); 88 MemoryDumpProvider::Options options);
89 void UnregisterDumpProvider(MemoryDumpProvider* mdp); 89 void UnregisterDumpProvider(MemoryDumpProvider* mdp);
90 90
91 // Unregisters an unbound dump provider and takes care about its deletion 91 // Unregisters an unbound dump provider and takes care about its deletion
92 // asynchronously. Can be used only for for dump providers with no 92 // asynchronously. Can be used only for for dump providers with no
93 // task-runner affinity. 93 // task-runner affinity.
94 // This method takes ownership of the dump provider and guarantees that: 94 // This method takes ownership of the dump provider and guarantees that:
95 // - The |mdp| will be deleted at some point in the near future. 95 // - The |mdp| will be deleted at some point in the near future.
96 // - Its deletion will not happen concurrently with the OnMemoryDump() call. 96 // - Its deletion will not happen concurrently with the OnMemoryDump() call.
97 // Note that OnMemoryDump() calls can still happen after this method returns. 97 // Note that OnMemoryDump() and PollFastMemoryTotal() calls can still happen
98 // after this method returns.
98 void UnregisterAndDeleteDumpProviderSoon( 99 void UnregisterAndDeleteDumpProviderSoon(
99 std::unique_ptr<MemoryDumpProvider> mdp); 100 std::unique_ptr<MemoryDumpProvider> mdp);
100 101
101 // Requests a memory dump. The dump might happen or not depending on the 102 // Requests a memory dump. The dump might happen or not depending on the
102 // filters and categories specified when enabling tracing. 103 // filters and categories specified when enabling tracing.
103 // The optional |callback| is executed asynchronously, on an arbitrary thread, 104 // The optional |callback| is executed asynchronously, on an arbitrary thread,
104 // to notify about the completion of the global dump (i.e. after all the 105 // to notify about the completion of the global dump (i.e. after all the
105 // processes have dumped) and its success (true iff all the dumps were 106 // processes have dumped) and its success (true iff all the dumps were
106 // successful). 107 // successful).
107 void RequestGlobalDump(MemoryDumpType dump_type, 108 void RequestGlobalDump(MemoryDumpType dump_type,
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 // the MDP while registration. On failure to do so, skips and continues to 323 // the MDP while registration. On failure to do so, skips and continues to
323 // next MDP. 324 // next MDP.
324 void SetupNextMemoryDump( 325 void SetupNextMemoryDump(
325 std::unique_ptr<ProcessMemoryDumpAsyncState> pmd_async_state); 326 std::unique_ptr<ProcessMemoryDumpAsyncState> pmd_async_state);
326 327
327 // Invokes OnMemoryDump() of the next MDP and calls SetupNextMemoryDump() at 328 // Invokes OnMemoryDump() of the next MDP and calls SetupNextMemoryDump() at
328 // the end to continue the ProcessMemoryDump. Should be called on the MDP task 329 // the end to continue the ProcessMemoryDump. Should be called on the MDP task
329 // runner. 330 // runner.
330 void InvokeOnMemoryDump(ProcessMemoryDumpAsyncState* owned_pmd_async_state); 331 void InvokeOnMemoryDump(ProcessMemoryDumpAsyncState* owned_pmd_async_state);
331 332
333 // Records a quick total memory usage in |memory_total|. This is used to track
334 // and detect peaks in the memory usage of the process without having to
335 // record all data from dump providers. This value is approximate to trade-off
336 // speed, and not consistent with the rest of the memory-infra metrics. Must
337 // be called on the dump thread.
338 void PollFastMemoryTotal(uint64_t* memory_total);
339
332 // Helper for RegierDumpProvider* functions. 340 // Helper for RegierDumpProvider* functions.
333 void RegisterDumpProviderInternal( 341 void RegisterDumpProviderInternal(
334 MemoryDumpProvider* mdp, 342 MemoryDumpProvider* mdp,
335 const char* name, 343 const char* name,
336 scoped_refptr<SequencedTaskRunner> task_runner, 344 scoped_refptr<SequencedTaskRunner> task_runner,
337 const MemoryDumpProvider::Options& options); 345 const MemoryDumpProvider::Options& options);
338 346
339 // Helper for the public UnregisterDumpProvider* functions. 347 // Helper for the public UnregisterDumpProvider* functions.
340 void UnregisterDumpProviderInternal(MemoryDumpProvider* mdp, 348 void UnregisterDumpProviderInternal(MemoryDumpProvider* mdp,
341 bool take_mdp_ownership_and_delete_async); 349 bool take_mdp_ownership_and_delete_async);
342 350
351 // Adds / removes provider that supports polling to
352 // |dump_providers_for_polling_|.
353 void RegisterPollingMDPOnDumpThread(
354 scoped_refptr<MemoryDumpProviderInfo> mdpinfo);
355 void UnregisterPollingMDPOnDumpThread(
356 scoped_refptr<MemoryDumpProviderInfo> mdpinfo);
357
343 // An ordererd set of registered MemoryDumpProviderInfo(s), sorted by task 358 // An ordererd set of registered MemoryDumpProviderInfo(s), sorted by task
344 // runner affinity (MDPs belonging to the same task runners are adjacent). 359 // runner affinity (MDPs belonging to the same task runners are adjacent).
345 MemoryDumpProviderInfo::OrderedSet dump_providers_; 360 MemoryDumpProviderInfo::OrderedSet dump_providers_;
346 361
362 // A copy of mdpinfo list that support polling. It must be accessed only on
363 // the dump thread if dump thread exists.
364 MemoryDumpProviderInfo::OrderedSet dump_providers_for_polling_;
365
347 // Shared among all the PMDs to keep state scoped to the tracing session. 366 // Shared among all the PMDs to keep state scoped to the tracing session.
348 scoped_refptr<MemoryDumpSessionState> session_state_; 367 scoped_refptr<MemoryDumpSessionState> session_state_;
349 368
350 MemoryDumpManagerDelegate* delegate_; // Not owned. 369 MemoryDumpManagerDelegate* delegate_; // Not owned.
351 370
352 // When true, this instance is in charge of coordinating periodic dumps. 371 // When true, this instance is in charge of coordinating periodic dumps.
353 bool is_coordinator_; 372 bool is_coordinator_;
354 373
355 // Protects from concurrent accesses to the |dump_providers_*| and |delegate_| 374 // Protects from concurrent accesses to the |dump_providers_*| and |delegate_|
356 // to guard against disabling logging while dumping on another thread. 375 // to guard against disabling logging while dumping on another thread.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 } 420 }
402 421
403 private: 422 private:
404 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegate); 423 DISALLOW_COPY_AND_ASSIGN(MemoryDumpManagerDelegate);
405 }; 424 };
406 425
407 } // namespace trace_event 426 } // namespace trace_event
408 } // namespace base 427 } // namespace base
409 428
410 #endif // BASE_TRACE_EVENT_MEMORY_DUMP_MANAGER_H_ 429 #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