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

Side by Side Diff: third_party/WebKit/Source/platform/heap/BlinkGCMemoryDumpProvider.cpp

Issue 2650863003: [tracing] Switch to new heap dump format. (Closed)
Patch Set: Address comments (heaps_v2) Created 3 years, 9 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 "platform/heap/BlinkGCMemoryDumpProvider.h" 5 #include "platform/heap/BlinkGCMemoryDumpProvider.h"
6 6
7 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" 7 #include "base/trace_event/heap_profiler_allocation_context_tracker.h"
8 #include "base/trace_event/heap_profiler_allocation_register.h" 8 #include "base/trace_event/heap_profiler_allocation_register.h"
9 #include "base/trace_event/memory_allocator_dump.h" 9 #include "base/trace_event/memory_allocator_dump.h"
10 #include "base/trace_event/process_memory_dump.h" 10 #include "base/trace_event/process_memory_dump.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 MemoryDumpLevelOfDetail levelOfDetail = args.level_of_detail; 57 MemoryDumpLevelOfDetail levelOfDetail = args.level_of_detail;
58 // In the case of a detailed dump perform a mark-only GC pass to collect 58 // In the case of a detailed dump perform a mark-only GC pass to collect
59 // more detailed stats. 59 // more detailed stats.
60 if (levelOfDetail == MemoryDumpLevelOfDetail::DETAILED) 60 if (levelOfDetail == MemoryDumpLevelOfDetail::DETAILED)
61 ThreadState::current()->collectGarbage(BlinkGC::NoHeapPointersOnStack, 61 ThreadState::current()->collectGarbage(BlinkGC::NoHeapPointersOnStack,
62 BlinkGC::TakeSnapshot, 62 BlinkGC::TakeSnapshot,
63 BlinkGC::ForcedGC); 63 BlinkGC::ForcedGC);
64 dumpMemoryTotals(memoryDump); 64 dumpMemoryTotals(memoryDump);
65 65
66 if (m_isHeapProfilingEnabled) { 66 if (m_isHeapProfilingEnabled) {
67 // Overhead should always be reported, regardless of light vs. heavy. 67 MutexLocker locker(m_allocationRegisterMutex);
68 base::trace_event::TraceEventMemoryOverhead overhead; 68 memoryDump->DumpHeapUsage(*m_allocationRegister, "blink_gc");
69 base::hash_map<base::trace_event::AllocationContext,
70 base::trace_event::AllocationMetrics>
71 metricsByContext;
72 {
73 MutexLocker locker(m_allocationRegisterMutex);
74 if (levelOfDetail == MemoryDumpLevelOfDetail::DETAILED) {
75 for (const auto& allocSize : *m_allocationRegister) {
76 base::trace_event::AllocationMetrics& metrics =
77 metricsByContext[allocSize.context];
78 metrics.size += allocSize.size;
79 metrics.count++;
80 }
81 }
82 m_allocationRegister->EstimateTraceMemoryOverhead(&overhead);
83 }
84 memoryDump->DumpHeapUsage(metricsByContext, overhead, "blink_gc");
85 } 69 }
86 70
87 // Merge all dumps collected by ThreadHeap::collectGarbage. 71 // Merge all dumps collected by ThreadHeap::collectGarbage.
88 if (levelOfDetail == MemoryDumpLevelOfDetail::DETAILED) 72 if (levelOfDetail == MemoryDumpLevelOfDetail::DETAILED)
89 memoryDump->TakeAllDumpsFrom(m_currentProcessMemoryDump.get()); 73 memoryDump->TakeAllDumpsFrom(m_currentProcessMemoryDump.get());
90 return true; 74 return true;
91 } 75 }
92 76
93 void BlinkGCMemoryDumpProvider::OnHeapProfilingEnabled(bool enabled) { 77 void BlinkGCMemoryDumpProvider::OnHeapProfilingEnabled(bool enabled) {
94 if (enabled) { 78 if (enabled) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 m_allocationRegister->Insert(address, size, context); 122 m_allocationRegister->Insert(address, size, context);
139 } 123 }
140 124
141 void BlinkGCMemoryDumpProvider::remove(Address address) { 125 void BlinkGCMemoryDumpProvider::remove(Address address) {
142 MutexLocker locker(m_allocationRegisterMutex); 126 MutexLocker locker(m_allocationRegisterMutex);
143 if (m_allocationRegister) 127 if (m_allocationRegister)
144 m_allocationRegister->Remove(address); 128 m_allocationRegister->Remove(address);
145 } 129 }
146 130
147 } // namespace blink 131 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698