OLD | NEW |
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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 void RequestPeriodicGlobalDump() { | 50 void RequestPeriodicGlobalDump() { |
51 MemoryDumpArgs::LevelOfDetail dump_level_of_detail; | 51 MemoryDumpArgs::LevelOfDetail dump_level_of_detail; |
52 if (g_heavy_dumps_rate == 0) { | 52 if (g_heavy_dumps_rate == 0) { |
53 dump_level_of_detail = MemoryDumpArgs::LevelOfDetail::LOW; | 53 dump_level_of_detail = MemoryDumpArgs::LevelOfDetail::LOW; |
54 } else { | 54 } else { |
55 dump_level_of_detail = g_periodic_dumps_count == 0 | 55 dump_level_of_detail = g_periodic_dumps_count == 0 |
56 ? MemoryDumpArgs::LevelOfDetail::HIGH | 56 ? MemoryDumpArgs::LevelOfDetail::HIGH |
57 : MemoryDumpArgs::LevelOfDetail::LOW; | 57 : MemoryDumpArgs::LevelOfDetail::LOW; |
58 | 58 |
59 if (++g_periodic_dumps_count == g_heavy_dumps_rate - 1) | 59 if (++g_periodic_dumps_count == g_heavy_dumps_rate) |
60 g_periodic_dumps_count = 0; | 60 g_periodic_dumps_count = 0; |
61 } | 61 } |
62 | 62 |
63 MemoryDumpArgs dump_args = {dump_level_of_detail}; | 63 MemoryDumpArgs dump_args = {dump_level_of_detail}; |
64 MemoryDumpManager::GetInstance()->RequestGlobalDump( | 64 MemoryDumpManager::GetInstance()->RequestGlobalDump( |
65 MemoryDumpType::PERIODIC_INTERVAL, dump_args); | 65 MemoryDumpType::PERIODIC_INTERVAL, dump_args); |
66 } | 66 } |
67 | 67 |
68 } // namespace | 68 } // namespace |
69 | 69 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 if (instance) | 102 if (instance) |
103 instance->skip_core_dumpers_auto_registration_for_testing_ = true; | 103 instance->skip_core_dumpers_auto_registration_for_testing_ = true; |
104 g_instance_for_testing = instance; | 104 g_instance_for_testing = instance; |
105 } | 105 } |
106 | 106 |
107 MemoryDumpManager::MemoryDumpManager() | 107 MemoryDumpManager::MemoryDumpManager() |
108 : delegate_(nullptr), | 108 : delegate_(nullptr), |
109 is_coordinator_(false), | 109 is_coordinator_(false), |
110 memory_tracing_enabled_(0), | 110 memory_tracing_enabled_(0), |
111 tracing_process_id_(kInvalidTracingProcessId), | 111 tracing_process_id_(kInvalidTracingProcessId), |
112 skip_core_dumpers_auto_registration_for_testing_(false), | 112 skip_core_dumpers_auto_registration_for_testing_(false) { |
113 disable_periodic_dumps_for_testing_(false) { | |
114 g_next_guid.GetNext(); // Make sure that first guid is not zero. | 113 g_next_guid.GetNext(); // Make sure that first guid is not zero. |
115 } | 114 } |
116 | 115 |
117 MemoryDumpManager::~MemoryDumpManager() { | 116 MemoryDumpManager::~MemoryDumpManager() { |
118 TraceLog::GetInstance()->RemoveEnabledStateObserver(this); | 117 TraceLog::GetInstance()->RemoveEnabledStateObserver(this); |
119 } | 118 } |
120 | 119 |
121 void MemoryDumpManager::Initialize(MemoryDumpManagerDelegate* delegate, | 120 void MemoryDumpManager::Initialize(MemoryDumpManagerDelegate* delegate, |
122 bool is_coordinator) { | 121 bool is_coordinator) { |
123 { | 122 { |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 for (auto it = dump_providers_.begin(); it != dump_providers_.end(); ++it) { | 418 for (auto it = dump_providers_.begin(); it != dump_providers_.end(); ++it) { |
420 it->disabled = false; | 419 it->disabled = false; |
421 it->consecutive_failures = 0; | 420 it->consecutive_failures = 0; |
422 } | 421 } |
423 | 422 |
424 subtle::NoBarrier_Store(&memory_tracing_enabled_, 1); | 423 subtle::NoBarrier_Store(&memory_tracing_enabled_, 1); |
425 | 424 |
426 // TODO(primiano): This is a temporary hack to disable periodic memory dumps | 425 // TODO(primiano): This is a temporary hack to disable periodic memory dumps |
427 // when running memory benchmarks until telemetry uses TraceConfig to | 426 // when running memory benchmarks until telemetry uses TraceConfig to |
428 // enable/disable periodic dumps. See crbug.com/529184 . | 427 // enable/disable periodic dumps. See crbug.com/529184 . |
429 // The same mechanism should be used to disable periodic dumps in tests. | |
430 if (!is_coordinator_ || | 428 if (!is_coordinator_ || |
431 CommandLine::ForCurrentProcess()->HasSwitch( | 429 CommandLine::ForCurrentProcess()->HasSwitch( |
432 "enable-memory-benchmarking") || | 430 "enable-memory-benchmarking")) { |
433 disable_periodic_dumps_for_testing_) { | |
434 return; | 431 return; |
435 } | 432 } |
436 | 433 |
437 // Enable periodic dumps. At the moment the periodic support is limited to at | 434 // Enable periodic dumps. At the moment the periodic support is limited to at |
438 // most one low-detail periodic dump and at most one high-detail periodic | 435 // most one low-detail periodic dump and at most one high-detail periodic |
439 // dump. If both are specified the high-detail period must be an integer | 436 // dump. If both are specified the high-detail period must be an integer |
440 // multiple of the low-level one. | 437 // multiple of the low-level one. |
441 g_periodic_dumps_count = 0; | 438 g_periodic_dumps_count = 0; |
442 const TraceConfig trace_config = | 439 const TraceConfig trace_config = |
443 TraceLog::GetInstance()->GetCurrentTraceConfig(); | 440 TraceLog::GetInstance()->GetCurrentTraceConfig(); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 next_dump_provider(next_dump_provider), | 501 next_dump_provider(next_dump_provider), |
505 callback(callback), | 502 callback(callback), |
506 task_runner(MessageLoop::current()->task_runner()) { | 503 task_runner(MessageLoop::current()->task_runner()) { |
507 } | 504 } |
508 | 505 |
509 MemoryDumpManager::ProcessMemoryDumpAsyncState::~ProcessMemoryDumpAsyncState() { | 506 MemoryDumpManager::ProcessMemoryDumpAsyncState::~ProcessMemoryDumpAsyncState() { |
510 } | 507 } |
511 | 508 |
512 } // namespace trace_event | 509 } // namespace trace_event |
513 } // namespace base | 510 } // namespace base |
OLD | NEW |