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

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

Issue 1877313003: [tracing] Track number of allocations in heap profiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clean up Created 4 years, 8 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/trace_event_memory_overhead.h" 9 #include "base/trace_event/trace_event_memory_overhead.h"
10 #include "platform/heap/Handle.h" 10 #include "platform/heap/Handle.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 { 57 {
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 == WebMemoryDumpLevelOfDetail::Detailed) 60 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed)
61 Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::TakeSnapsh ot, BlinkGC::ForcedGC); 61 Heap::collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::TakeSnapsh ot, BlinkGC::ForcedGC);
62 dumpMemoryTotals(memoryDump); 62 dumpMemoryTotals(memoryDump);
63 63
64 if (m_isHeapProfilingEnabled) { 64 if (m_isHeapProfilingEnabled) {
65 // Overhead should always be reported, regardless of light vs. heavy. 65 // Overhead should always be reported, regardless of light vs. heavy.
66 base::trace_event::TraceEventMemoryOverhead overhead; 66 base::trace_event::TraceEventMemoryOverhead overhead;
67 base::hash_map<base::trace_event::AllocationContext, size_t> bytesByCont ext; 67 base::hash_map<base::trace_event::AllocationContext, base::trace_event:: AllocationsSizeAndCount> metricsByContext;
68 { 68 {
69 MutexLocker locker(m_allocationRegisterMutex); 69 MutexLocker locker(m_allocationRegisterMutex);
70 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) { 70 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) {
71 for (const auto& allocSize : *m_allocationRegister) 71 for (const auto& allocSize : *m_allocationRegister) {
72 bytesByContext[allocSize.context] += allocSize.size; 72 metricsByContext[allocSize.context].size += allocSize.size;
73 metricsByContext[allocSize.context].count++;
Dmitry Skiba 2016/04/14 19:07:30 Avoid second lookup.
ssid 2016/04/14 20:17:11 Done.
74 }
73 } 75 }
74 m_allocationRegister->EstimateTraceMemoryOverhead(&overhead); 76 m_allocationRegister->EstimateTraceMemoryOverhead(&overhead);
75 } 77 }
76 memoryDump->dumpHeapUsage(bytesByContext, overhead, "blink_gc"); 78 memoryDump->dumpHeapUsage(metricsByContext, overhead, "blink_gc");
77 } 79 }
78 80
79 // Merge all dumps collected by Heap::collectGarbage. 81 // Merge all dumps collected by Heap::collectGarbage.
80 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) 82 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed)
81 memoryDump->takeAllDumpsFrom(m_currentProcessMemoryDump.get()); 83 memoryDump->takeAllDumpsFrom(m_currentProcessMemoryDump.get());
82 return true; 84 return true;
83 } 85 }
84 86
85 void BlinkGCMemoryDumpProvider::onHeapProfilingEnabled(bool enabled) 87 void BlinkGCMemoryDumpProvider::onHeapProfilingEnabled(bool enabled)
86 { 88 {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 127 }
126 128
127 void BlinkGCMemoryDumpProvider::remove(Address address) 129 void BlinkGCMemoryDumpProvider::remove(Address address)
128 { 130 {
129 MutexLocker locker(m_allocationRegisterMutex); 131 MutexLocker locker(m_allocationRegisterMutex);
130 if (m_allocationRegister) 132 if (m_allocationRegister)
131 m_allocationRegister->Remove(address); 133 m_allocationRegister->Remove(address);
132 } 134 }
133 135
134 } // namespace blink 136 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698