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

Side by Side Diff: third_party/WebKit/Source/platform/PartitionAllocMemoryDumpProvider.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/PartitionAllocMemoryDumpProvider.h" 5 #include "platform/PartitionAllocMemoryDumpProvider.h"
6 6
7 #include "base/trace_event/heap_profiler_allocation_context.h" 7 #include "base/trace_event/heap_profiler_allocation_context.h"
8 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" 8 #include "base/trace_event/heap_profiler_allocation_context_tracker.h"
9 #include "base/trace_event/heap_profiler_allocation_register.h" 9 #include "base/trace_event/heap_profiler_allocation_register.h"
10 #include "base/trace_event/process_memory_dump.h" 10 #include "base/trace_event/process_memory_dump.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 { 105 {
106 DEFINE_STATIC_LOCAL(PartitionAllocMemoryDumpProvider, instance, ()); 106 DEFINE_STATIC_LOCAL(PartitionAllocMemoryDumpProvider, instance, ());
107 return &instance; 107 return &instance;
108 } 108 }
109 109
110 bool PartitionAllocMemoryDumpProvider::onMemoryDump(WebMemoryDumpLevelOfDetail l evelOfDetail, WebProcessMemoryDump* memoryDump) 110 bool PartitionAllocMemoryDumpProvider::onMemoryDump(WebMemoryDumpLevelOfDetail l evelOfDetail, WebProcessMemoryDump* memoryDump)
111 { 111 {
112 if (m_isHeapProfilingEnabled) { 112 if (m_isHeapProfilingEnabled) {
113 // Overhead should always be reported, regardless of light vs. heavy. 113 // Overhead should always be reported, regardless of light vs. heavy.
114 base::trace_event::TraceEventMemoryOverhead overhead; 114 base::trace_event::TraceEventMemoryOverhead overhead;
115 base::hash_map<base::trace_event::AllocationContext, size_t> bytesByCont ext; 115 base::hash_map<base::trace_event::AllocationContext, base::trace_event:: AllocationsSizeAndCount> metricsByContext;
Dmitry Skiba 2016/04/14 19:07:30 I wonder if we should have typedef for this, like
Primiano Tucci (use gerrit) 2016/04/14 19:37:21 IMHO typedef just make the code less readable as y
ssid 2016/04/14 20:17:10 Acknowledged.
116 { 116 {
117 MutexLocker locker(m_allocationRegisterMutex); 117 MutexLocker locker(m_allocationRegisterMutex);
118 // Dump only the overhead estimation in non-detailed dumps. 118 // Dump only the overhead estimation in non-detailed dumps.
119 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) { 119 if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) {
120 for (const auto& allocSize : *m_allocationRegister) 120 for (const auto& allocSize : *m_allocationRegister) {
121 bytesByContext[allocSize.context] += allocSize.size; 121 metricsByContext[allocSize.context].size += allocSize.size;
122 metricsByContext[allocSize.context].count++;
Dmitry Skiba 2016/04/14 19:07:30 Avoid second lookup.
ssid 2016/04/14 20:17:10 Done.
123 }
122 } 124 }
123 m_allocationRegister->EstimateTraceMemoryOverhead(&overhead); 125 m_allocationRegister->EstimateTraceMemoryOverhead(&overhead);
124 } 126 }
125 memoryDump->dumpHeapUsage(bytesByContext, overhead, "partition_alloc"); 127 memoryDump->dumpHeapUsage(metricsByContext, overhead, "partition_alloc") ;
126 } 128 }
127 129
128 PartitionStatsDumperImpl partitionStatsDumper(memoryDump, levelOfDetail); 130 PartitionStatsDumperImpl partitionStatsDumper(memoryDump, levelOfDetail);
129 131
130 WebMemoryAllocatorDump* partitionsDump = memoryDump->createMemoryAllocatorDu mp( 132 WebMemoryAllocatorDump* partitionsDump = memoryDump->createMemoryAllocatorDu mp(
131 String::format("%s/%s", kPartitionAllocDumpName, kPartitionsDumpName)); 133 String::format("%s/%s", kPartitionAllocDumpName, kPartitionsDumpName));
132 134
133 // This method calls memoryStats.partitionsDumpBucketStats with memory stati stics. 135 // This method calls memoryStats.partitionsDumpBucketStats with memory stati stics.
134 WTF::Partitions::dumpMemoryStats(levelOfDetail == WebMemoryDumpLevelOfDetail ::Light, &partitionStatsDumper); 136 WTF::Partitions::dumpMemoryStats(levelOfDetail == WebMemoryDumpLevelOfDetail ::Light, &partitionStatsDumper);
135 137
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 } 180 }
179 181
180 void PartitionAllocMemoryDumpProvider::remove(void* address) 182 void PartitionAllocMemoryDumpProvider::remove(void* address)
181 { 183 {
182 MutexLocker locker(m_allocationRegisterMutex); 184 MutexLocker locker(m_allocationRegisterMutex);
183 if (m_allocationRegister) 185 if (m_allocationRegister)
184 m_allocationRegister->Remove(address); 186 m_allocationRegister->Remove(address);
185 } 187 }
186 188
187 } // namespace blink 189 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698