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

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

Issue 2049143002: [memory-infra] Log reasons for memory dump failure (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Shorten constant name Created 4 years, 6 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 #include <utility> 8 #include <utility>
9 9
10 #include "base/atomic_sequence_num.h" 10 #include "base/atomic_sequence_num.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 GetterFunctPtr const getter_function; 91 GetterFunctPtr const getter_function;
92 }; 92 };
93 93
94 } // namespace 94 } // namespace
95 95
96 // static 96 // static
97 const char* const MemoryDumpManager::kTraceCategory = 97 const char* const MemoryDumpManager::kTraceCategory =
98 TRACE_DISABLED_BY_DEFAULT("memory-infra"); 98 TRACE_DISABLED_BY_DEFAULT("memory-infra");
99 99
100 // static 100 // static
101 const char* const MemoryDumpManager::kLogPrefix = "Memory-infra dump";
102
103 // static
101 const int MemoryDumpManager::kMaxConsecutiveFailuresCount = 3; 104 const int MemoryDumpManager::kMaxConsecutiveFailuresCount = 3;
102 105
103 // static 106 // static
104 const uint64_t MemoryDumpManager::kInvalidTracingProcessId = 0; 107 const uint64_t MemoryDumpManager::kInvalidTracingProcessId = 0;
105 108
106 // static 109 // static
107 const char* const MemoryDumpManager::kSystemAllocatorPoolName = 110 const char* const MemoryDumpManager::kSystemAllocatorPoolName =
108 #if defined(MALLOC_MEMORY_TRACING_SUPPORTED) 111 #if defined(MALLOC_MEMORY_TRACING_SUPPORTED)
109 MallocDumpProvider::kAllocatedObjects; 112 MallocDumpProvider::kAllocatedObjects;
110 #elif defined(OS_WIN) 113 #elif defined(OS_WIN)
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 (*mdp_iter)->disabled = true; 333 (*mdp_iter)->disabled = true;
331 dump_providers_.erase(mdp_iter); 334 dump_providers_.erase(mdp_iter);
332 } 335 }
333 336
334 void MemoryDumpManager::RequestGlobalDump( 337 void MemoryDumpManager::RequestGlobalDump(
335 MemoryDumpType dump_type, 338 MemoryDumpType dump_type,
336 MemoryDumpLevelOfDetail level_of_detail, 339 MemoryDumpLevelOfDetail level_of_detail,
337 const MemoryDumpCallback& callback) { 340 const MemoryDumpCallback& callback) {
338 // Bail out immediately if tracing is not enabled at all. 341 // Bail out immediately if tracing is not enabled at all.
339 if (!UNLIKELY(subtle::NoBarrier_Load(&memory_tracing_enabled_))) { 342 if (!UNLIKELY(subtle::NoBarrier_Load(&memory_tracing_enabled_))) {
343 VLOG(1) << kLogPrefix << " failed because " << kTraceCategory
344 << " tracing category is not enabled";
340 if (!callback.is_null()) 345 if (!callback.is_null())
341 callback.Run(0u /* guid */, false /* success */); 346 callback.Run(0u /* guid */, false /* success */);
342 return; 347 return;
343 } 348 }
344 349
345 const uint64_t guid = 350 const uint64_t guid =
346 TraceLog::GetInstance()->MangleEventId(g_next_guid.GetNext()); 351 TraceLog::GetInstance()->MangleEventId(g_next_guid.GetNext());
347 352
348 // Creates an async event to keep track of the global dump evolution. 353 // Creates an async event to keep track of the global dump evolution.
349 // The |wrapped_callback| will generate the ASYNC_END event and then invoke 354 // The |wrapped_callback| will generate the ASYNC_END event and then invoke
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 // Initalizes the ThreadLocalEventBuffer to guarantee that the TRACE_EVENTs 420 // Initalizes the ThreadLocalEventBuffer to guarantee that the TRACE_EVENTs
416 // in the PostTask below don't end up registering their own dump providers 421 // in the PostTask below don't end up registering their own dump providers
417 // (for discounting trace memory overhead) while holding the |lock_|. 422 // (for discounting trace memory overhead) while holding the |lock_|.
418 TraceLog::GetInstance()->InitializeThreadLocalEventBufferIfSupported(); 423 TraceLog::GetInstance()->InitializeThreadLocalEventBufferIfSupported();
419 424
420 // |dump_thread_| might be destroyed before getting this point. 425 // |dump_thread_| might be destroyed before getting this point.
421 // It means that tracing was disabled right before starting this dump. 426 // It means that tracing was disabled right before starting this dump.
422 // Anyway either tracing is stopped or this was the last hop, create a trace 427 // Anyway either tracing is stopped or this was the last hop, create a trace
423 // event, add it to the trace and finalize process dump invoking the callback. 428 // event, add it to the trace and finalize process dump invoking the callback.
424 if (!pmd_async_state->dump_thread_task_runner.get()) { 429 if (!pmd_async_state->dump_thread_task_runner.get()) {
430 if (pmd_async_state->pending_dump_providers.empty()) {
431 VLOG(1) << kLogPrefix << " failed because dump thread was destroyed"
432 << " before finalizing the dump";
433 } else {
434 VLOG(1) << kLogPrefix << " failed because dump thread was destroyed"
435 << " before dumping "
436 << pmd_async_state->pending_dump_providers.back().get()->name;
437 }
425 pmd_async_state->dump_successful = false; 438 pmd_async_state->dump_successful = false;
426 pmd_async_state->pending_dump_providers.clear(); 439 pmd_async_state->pending_dump_providers.clear();
427 } 440 }
428 if (pmd_async_state->pending_dump_providers.empty()) 441 if (pmd_async_state->pending_dump_providers.empty())
429 return FinalizeDumpAndAddToTrace(std::move(pmd_async_state)); 442 return FinalizeDumpAndAddToTrace(std::move(pmd_async_state));
430 443
431 // Read MemoryDumpProviderInfo thread safety considerations in 444 // Read MemoryDumpProviderInfo thread safety considerations in
432 // memory_dump_manager.h when accessing |mdpinfo| fields. 445 // memory_dump_manager.h when accessing |mdpinfo| fields.
433 MemoryDumpProviderInfo* mdpinfo = 446 MemoryDumpProviderInfo* mdpinfo =
434 pmd_async_state->pending_dump_providers.back().get(); 447 pmd_async_state->pending_dump_providers.back().get();
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 TRACE_EVENT_PHASE_MEMORY_DUMP, 602 TRACE_EVENT_PHASE_MEMORY_DUMP,
590 TraceLog::GetCategoryGroupEnabled(kTraceCategory), event_name, 603 TraceLog::GetCategoryGroupEnabled(kTraceCategory), event_name,
591 trace_event_internal::kGlobalScope, dump_guid, pid, 604 trace_event_internal::kGlobalScope, dump_guid, pid,
592 kTraceEventNumArgs, kTraceEventArgNames, 605 kTraceEventNumArgs, kTraceEventArgNames,
593 kTraceEventArgTypes, nullptr /* arg_values */, &event_value, 606 kTraceEventArgTypes, nullptr /* arg_values */, &event_value,
594 TRACE_EVENT_FLAG_HAS_ID); 607 TRACE_EVENT_FLAG_HAS_ID);
595 } 608 }
596 609
597 bool tracing_still_enabled; 610 bool tracing_still_enabled;
598 TRACE_EVENT_CATEGORY_GROUP_ENABLED(kTraceCategory, &tracing_still_enabled); 611 TRACE_EVENT_CATEGORY_GROUP_ENABLED(kTraceCategory, &tracing_still_enabled);
599 if (!tracing_still_enabled) 612 if (!tracing_still_enabled) {
600 pmd_async_state->dump_successful = false; 613 pmd_async_state->dump_successful = false;
614 VLOG(1) << kLogPrefix << " failed because tracing was disabled before"
615 << " the dump was completed";
616 }
601 617
602 if (!pmd_async_state->callback.is_null()) { 618 if (!pmd_async_state->callback.is_null()) {
603 pmd_async_state->callback.Run(dump_guid, pmd_async_state->dump_successful); 619 pmd_async_state->callback.Run(dump_guid, pmd_async_state->dump_successful);
604 pmd_async_state->callback.Reset(); 620 pmd_async_state->callback.Reset();
605 } 621 }
606 622
607 TRACE_EVENT_NESTABLE_ASYNC_END0(kTraceCategory, "ProcessMemoryDump", 623 TRACE_EVENT_NESTABLE_ASYNC_END0(kTraceCategory, "ProcessMemoryDump",
608 TRACE_ID_MANGLE(dump_guid)); 624 TRACE_ID_MANGLE(dump_guid));
609 } 625 }
610 626
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 if (heavy_dump_rate_ > 0 && periodic_dumps_count_ % heavy_dump_rate_ == 0) 836 if (heavy_dump_rate_ > 0 && periodic_dumps_count_ % heavy_dump_rate_ == 0)
821 level_of_detail = MemoryDumpLevelOfDetail::DETAILED; 837 level_of_detail = MemoryDumpLevelOfDetail::DETAILED;
822 ++periodic_dumps_count_; 838 ++periodic_dumps_count_;
823 839
824 MemoryDumpManager::GetInstance()->RequestGlobalDump( 840 MemoryDumpManager::GetInstance()->RequestGlobalDump(
825 MemoryDumpType::PERIODIC_INTERVAL, level_of_detail); 841 MemoryDumpType::PERIODIC_INTERVAL, level_of_detail);
826 } 842 }
827 843
828 } // namespace trace_event 844 } // namespace trace_event
829 } // namespace base 845 } // namespace base
OLDNEW
« no previous file with comments | « base/trace_event/memory_dump_manager.h ('k') | components/tracing/child/child_memory_dump_manager_delegate_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698