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

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

Issue 1306753005: [tracing] Add memory dump config to TraceConfig (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits. Created 5 years, 4 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
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 <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 20 matching lines...) Expand all
31 31
32 #if defined(OS_WIN) 32 #if defined(OS_WIN)
33 #include "base/trace_event/winheap_dump_provider_win.h" 33 #include "base/trace_event/winheap_dump_provider_win.h"
34 #endif 34 #endif
35 35
36 namespace base { 36 namespace base {
37 namespace trace_event { 37 namespace trace_event {
38 38
39 namespace { 39 namespace {
40 40
41 // TODO(primiano): this should be smarter and should do something similar to
42 // trace event synthetic delays.
43 const char kTraceCategory[] = TRACE_DISABLED_BY_DEFAULT("memory-infra");
44
45 // Throttle mmaps at a rate of once every kHeavyMmapsDumpsRate standard dumps. 41 // Throttle mmaps at a rate of once every kHeavyMmapsDumpsRate standard dumps.
46 const int kHeavyDumpsRate = 8; // 250 ms * 8 = 2000 ms. 42 const int kHeavyDumpsRate = 8; // 250 ms * 8 = 2000 ms.
47 const int kDumpIntervalMs = 250; 43 const int kDumpIntervalMs = 250;
48 const int kTraceEventNumArgs = 1; 44 const int kTraceEventNumArgs = 1;
49 const char* kTraceEventArgNames[] = {"dumps"}; 45 const char* kTraceEventArgNames[] = {"dumps"};
50 const unsigned char kTraceEventArgTypes[] = {TRACE_VALUE_TYPE_CONVERTABLE}; 46 const unsigned char kTraceEventArgTypes[] = {TRACE_VALUE_TYPE_CONVERTABLE};
51 47
52 StaticAtomicSequenceNumber g_next_guid; 48 StaticAtomicSequenceNumber g_next_guid;
53 uint32 g_periodic_dumps_count = 0; 49 uint32 g_periodic_dumps_count = 0;
54 MemoryDumpManager* g_instance_for_testing = nullptr; 50 MemoryDumpManager* g_instance_for_testing = nullptr;
55 51
56 void RequestPeriodicGlobalDump() { 52 void RequestPeriodicGlobalDump() {
57 MemoryDumpArgs::LevelOfDetail dump_level_of_detail = 53 MemoryDumpArgs::LevelOfDetail dump_level_of_detail =
58 g_periodic_dumps_count == 0 ? MemoryDumpArgs::LevelOfDetail::HIGH 54 g_periodic_dumps_count == 0 ? MemoryDumpArgs::LevelOfDetail::HIGH
59 : MemoryDumpArgs::LevelOfDetail::LOW; 55 : MemoryDumpArgs::LevelOfDetail::LOW;
60 if (++g_periodic_dumps_count == kHeavyDumpsRate) 56 if (++g_periodic_dumps_count == kHeavyDumpsRate)
61 g_periodic_dumps_count = 0; 57 g_periodic_dumps_count = 0;
62 58
63 MemoryDumpArgs dump_args = {dump_level_of_detail}; 59 MemoryDumpArgs dump_args = {dump_level_of_detail};
64 MemoryDumpManager::GetInstance()->RequestGlobalDump( 60 MemoryDumpManager::GetInstance()->RequestGlobalDump(
65 MemoryDumpType::PERIODIC_INTERVAL, dump_args); 61 MemoryDumpType::PERIODIC_INTERVAL, dump_args);
66 } 62 }
67 63
68 } // namespace 64 } // namespace
69 65
66 // TODO(primiano): this should be smarter and should do something similar to
Primiano Tucci (use gerrit) 2015/08/24 11:58:35 You can remove this todo in the next cl when you a
67 // trace event synthetic delays.
70 // static 68 // static
71 const char* const MemoryDumpManager::kTraceCategoryForTesting = kTraceCategory; 69 const char* const MemoryDumpManager::kTraceCategory =
70 TRACE_DISABLED_BY_DEFAULT("memory-infra");
72 71
73 // static 72 // static
74 const int MemoryDumpManager::kMaxConsecutiveFailuresCount = 3; 73 const int MemoryDumpManager::kMaxConsecutiveFailuresCount = 3;
75 74
76 // static 75 // static
77 const uint64 MemoryDumpManager::kInvalidTracingProcessId = 0; 76 const uint64 MemoryDumpManager::kInvalidTracingProcessId = 0;
78 77
79 // static 78 // static
80 MemoryDumpManager* MemoryDumpManager::GetInstance() { 79 MemoryDumpManager* MemoryDumpManager::GetInstance() {
81 if (g_instance_for_testing) 80 if (g_instance_for_testing)
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 next_dump_provider(next_dump_provider), 479 next_dump_provider(next_dump_provider),
481 callback(callback), 480 callback(callback),
482 task_runner(MessageLoop::current()->task_runner()) { 481 task_runner(MessageLoop::current()->task_runner()) {
483 } 482 }
484 483
485 MemoryDumpManager::ProcessMemoryDumpAsyncState::~ProcessMemoryDumpAsyncState() { 484 MemoryDumpManager::ProcessMemoryDumpAsyncState::~ProcessMemoryDumpAsyncState() {
486 } 485 }
487 486
488 } // namespace trace_event 487 } // namespace trace_event
489 } // namespace base 488 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698