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

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

Issue 2876543002: memory-infra: Don't invoke all dump providers in SUMMARY_ONLY mode (Closed)
Patch Set: address comments Created 3 years, 7 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 | « no previous file | base/trace_event/memory_dump_manager_unittest.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 #include "base/trace_event/memory_dump_manager.h" 5 #include "base/trace_event/memory_dump_manager.h"
6 6
7 #include <inttypes.h> 7 #include <inttypes.h>
8 #include <stdio.h> 8 #include <stdio.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 } 313 }
314 314
315 void MemoryDumpManager::RegisterDumpProviderInternal( 315 void MemoryDumpManager::RegisterDumpProviderInternal(
316 MemoryDumpProvider* mdp, 316 MemoryDumpProvider* mdp,
317 const char* name, 317 const char* name,
318 scoped_refptr<SequencedTaskRunner> task_runner, 318 scoped_refptr<SequencedTaskRunner> task_runner,
319 const MemoryDumpProvider::Options& options) { 319 const MemoryDumpProvider::Options& options) {
320 if (dumper_registrations_ignored_for_testing_) 320 if (dumper_registrations_ignored_for_testing_)
321 return; 321 return;
322 322
323 // A handful of MDPs are required to compute the summary struct these are
324 // 'whitelisted for summary mode'. These MDPs are a subset of those which
325 // have small enough performance overhead that it is resonable to run them
326 // in the background while the user is doing other things. Those MDPs are
327 // 'whitelisted for background mode'.
323 bool whitelisted_for_background_mode = IsMemoryDumpProviderWhitelisted(name); 328 bool whitelisted_for_background_mode = IsMemoryDumpProviderWhitelisted(name);
324 scoped_refptr<MemoryDumpProviderInfo> mdpinfo = 329 bool whitelisted_for_summary_mode =
325 new MemoryDumpProviderInfo(mdp, name, std::move(task_runner), options, 330 IsMemoryDumpProviderWhitelistedForSummary(name);
326 whitelisted_for_background_mode); 331
332 scoped_refptr<MemoryDumpProviderInfo> mdpinfo = new MemoryDumpProviderInfo(
333 mdp, name, std::move(task_runner), options,
334 whitelisted_for_background_mode, whitelisted_for_summary_mode);
327 335
328 if (options.is_fast_polling_supported) { 336 if (options.is_fast_polling_supported) {
329 DCHECK(!mdpinfo->task_runner) << "MemoryDumpProviders capable of fast " 337 DCHECK(!mdpinfo->task_runner) << "MemoryDumpProviders capable of fast "
330 "polling must NOT be thread bound."; 338 "polling must NOT be thread bound.";
331 } 339 }
332 340
333 { 341 {
334 AutoLock lock(lock_); 342 AutoLock lock(lock_);
335 bool already_registered = !dump_providers_.insert(mdpinfo).second; 343 bool already_registered = !dump_providers_.insert(mdpinfo).second;
336 // This actually happens in some tests which don't have a clean tear-down 344 // This actually happens in some tests which don't have a clean tear-down
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 564
557 // If we are in background tracing, we should invoke only the whitelisted 565 // If we are in background tracing, we should invoke only the whitelisted
558 // providers. Ignore other providers and continue. 566 // providers. Ignore other providers and continue.
559 if (pmd_async_state->req_args.level_of_detail == 567 if (pmd_async_state->req_args.level_of_detail ==
560 MemoryDumpLevelOfDetail::BACKGROUND && 568 MemoryDumpLevelOfDetail::BACKGROUND &&
561 !mdpinfo->whitelisted_for_background_mode) { 569 !mdpinfo->whitelisted_for_background_mode) {
562 pmd_async_state->pending_dump_providers.pop_back(); 570 pmd_async_state->pending_dump_providers.pop_back();
563 return SetupNextMemoryDump(std::move(pmd_async_state)); 571 return SetupNextMemoryDump(std::move(pmd_async_state));
564 } 572 }
565 573
574 // If we are in summary mode, we only need to invoke the providers
575 // whitelisted for summary mode.
576 if (pmd_async_state->req_args.dump_type == MemoryDumpType::SUMMARY_ONLY &&
577 !mdpinfo->whitelisted_for_summary_mode) {
578 pmd_async_state->pending_dump_providers.pop_back();
579 return SetupNextMemoryDump(std::move(pmd_async_state));
580 }
581
566 // If the dump provider did not specify a task runner affinity, dump on 582 // If the dump provider did not specify a task runner affinity, dump on
567 // |dump_thread_|. 583 // |dump_thread_|.
568 SequencedTaskRunner* task_runner = mdpinfo->task_runner.get(); 584 SequencedTaskRunner* task_runner = mdpinfo->task_runner.get();
569 if (!task_runner) { 585 if (!task_runner) {
570 DCHECK(mdpinfo->options.dumps_on_single_thread_task_runner); 586 DCHECK(mdpinfo->options.dumps_on_single_thread_task_runner);
571 task_runner = pmd_async_state->dump_thread_task_runner.get(); 587 task_runner = pmd_async_state->dump_thread_task_runner.get();
572 DCHECK(task_runner); 588 DCHECK(task_runner);
573 } 589 }
574 590
575 if (mdpinfo->options.dumps_on_single_thread_task_runner && 591 if (mdpinfo->options.dumps_on_single_thread_task_runner &&
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 if (iter == process_dumps.end()) { 903 if (iter == process_dumps.end()) {
888 std::unique_ptr<ProcessMemoryDump> new_pmd( 904 std::unique_ptr<ProcessMemoryDump> new_pmd(
889 new ProcessMemoryDump(heap_profiler_serialization_state, dump_args)); 905 new ProcessMemoryDump(heap_profiler_serialization_state, dump_args));
890 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first; 906 iter = process_dumps.insert(std::make_pair(pid, std::move(new_pmd))).first;
891 } 907 }
892 return iter->second.get(); 908 return iter->second.get();
893 } 909 }
894 910
895 } // namespace trace_event 911 } // namespace trace_event
896 } // namespace base 912 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/trace_event/memory_dump_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698